Skip to content

Commit af93d8d

Browse files
committed
cached symbol lookup
#perf
1 parent be736d3 commit af93d8d

20 files changed

+1285
-1966
lines changed

include/mrdocs/Corpus.hpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -66,31 +66,41 @@ class MRDOCS_VISIBLE
6666

6767
/** Return the begin iterator for the index of all symbols.
6868
*/
69-
MRDOCS_DECL
7069
virtual
7170
iterator
7271
begin() const noexcept = 0;
7372

7473
/** Return the end iterator for the index.
7574
*/
76-
MRDOCS_DECL
7775
virtual
7876
iterator
7977
end() const noexcept = 0;
8078

8179
/** Whether the corpus contains any symbols.
8280
*/
83-
MRDOCS_DECL
8481
bool
8582
empty() const noexcept;
8683

8784
/** Return the Info with the matching ID, or nullptr.
8885
*/
89-
MRDOCS_DECL
9086
virtual
9187
Info const*
9288
find(SymbolID const& id) const noexcept = 0;
9389

90+
/** Return the Info for the matching string in a given context.
91+
*/
92+
virtual
93+
Info const*
94+
lookup(SymbolID const& context, std::string_view name) const = 0;
95+
96+
/** Return the Info for the matching string in the global context.
97+
*/
98+
Info const*
99+
lookup(std::string_view name) const
100+
{
101+
return lookup(SymbolID::global, name);
102+
}
103+
94104
/** Return true if an Info with the specified symbol ID exists.
95105
96106
This function uses the @ref find function to locate
@@ -127,7 +137,6 @@ class MRDOCS_VISIBLE
127137
@ref get with the symbol ID for the
128138
global namespace.
129139
*/
130-
MRDOCS_DECL
131140
NamespaceInfo const&
132141
globalNamespace() const noexcept;
133142

@@ -327,11 +336,11 @@ class MRDOCS_VISIBLE
327336
328337
@return A reference to the string `temp`.
329338
*/
330-
MRDOCS_DECL
339+
virtual
331340
void
332341
qualifiedName(
333342
Info const& I,
334-
std::string& temp) const;
343+
std::string& temp) const = 0;
335344

336345
std::string
337346
qualifiedName(Info const& I) const

src/lib/Lib/Corpus.cpp

Lines changed: 0 additions & 53 deletions
Original file line numberDiff line numberDiff line change
@@ -49,59 +49,6 @@ globalNamespace() const noexcept
4949
//
5050
//------------------------------------------------
5151

52-
// KRYSTIAN NOTE: temporary
53-
void
54-
Corpus::
55-
qualifiedName(
56-
Info const& I,
57-
std::string& temp) const
58-
{
59-
temp.clear();
60-
if(! I.id || I.id == SymbolID::global)
61-
{
62-
return;
63-
}
64-
65-
MRDOCS_ASSERT(I.Parent);
66-
for(auto const& pID : getParents(*this, I))
67-
{
68-
if (!pID || pID == SymbolID::global)
69-
{
70-
continue;
71-
}
72-
if (Info const* P = find(pID))
73-
{
74-
if (!P->Name.empty())
75-
{
76-
temp.append(P->Name);
77-
}
78-
else
79-
{
80-
fmt::format_to(
81-
std::back_inserter(temp),
82-
"<unnamed {}>",
83-
toString(P->Kind));
84-
}
85-
}
86-
else
87-
{
88-
temp.append("<unnamed>");
89-
}
90-
temp.append("::");
91-
}
92-
if (I.Name.empty())
93-
{
94-
fmt::format_to(
95-
std::back_inserter(temp),
96-
"<unnamed {}>",
97-
toString(I.Kind));
98-
}
99-
else
100-
{
101-
temp.append(I.Name);
102-
}
103-
}
104-
10552
std::vector<SymbolID>
10653
getParents(Corpus const& C, Info const& I)
10754
{

0 commit comments

Comments
 (0)