Skip to content

Commit f92f1f2

Browse files
committed
Corpus qualified name returns void
#refactor
1 parent 7d8de21 commit f92f1f2

File tree

4 files changed

+33
-20
lines changed

4 files changed

+33
-20
lines changed

include/mrdocs/Corpus.hpp

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -197,18 +197,18 @@ class MRDOCS_VISIBLE
197197
198198
@return A reference to the string `temp`.
199199
*/
200-
// KRYSTIAN NOTE: temporary
201200
MRDOCS_DECL
202-
std::string&
203-
getFullyQualifiedName(
204-
const Info& I,
201+
void
202+
qualifiedName(
203+
Info const& I,
205204
std::string& temp) const;
206205

207206
std::string
208-
getFullyQualifiedName(const Info& I) const
207+
qualifiedName(const Info& I) const
209208
{
210209
std::string temp;
211-
return getFullyQualifiedName(I, temp);
210+
qualifiedName(I, temp);
211+
return temp;
212212
}
213213

214214
};

src/lib/Gen/xml/XMLWriter.cpp

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -161,24 +161,28 @@ writeIndex()
161161
tags_.open("symbols");
162162
if(options_.legible_names)
163163
{
164-
LegibleNames names(corpus_, true);
164+
LegibleNames const names(corpus_, true);
165165
for(auto& I : corpus_)
166166
{
167+
corpus_.qualifiedName(I, temp);
167168
auto legible_name = names.getUnqualified(I.id);
168169
tags_.write("symbol", {}, {
169170
{ "legible", legible_name },
170-
{ "name", corpus_.getFullyQualifiedName(I, temp) },
171+
{ "name", temp },
171172
{ "tag", toString(I.Kind) },
172173
{ I.id } });
173174
}
174175
}
175176
else
176177
{
177178
for(auto& I : corpus_)
179+
{
180+
corpus_.qualifiedName(I, temp);
178181
tags_.write("symbol", {}, {
179-
{ "name", corpus_.getFullyQualifiedName(I, temp) },
182+
{ "name", temp },
180183
{ "tag", toString(I.Kind) },
181184
{ I.id } });
185+
}
182186
}
183187
tags_.close("symbols");
184188
}

src/lib/Lib/Corpus.cpp

Lines changed: 17 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -51,15 +51,17 @@ globalNamespace() const noexcept
5151
//------------------------------------------------
5252

5353
// KRYSTIAN NOTE: temporary
54-
std::string&
54+
void
5555
Corpus::
56-
getFullyQualifiedName(
56+
qualifiedName(
5757
const Info& I,
5858
std::string& temp) const
5959
{
6060
temp.clear();
6161
if(! I.id || I.id == SymbolID::global)
62-
return temp;
62+
{
63+
return;
64+
}
6365

6466
MRDOCS_ASSERT(I.Parent);
6567
for(auto const& pID : getParents(*this, I))
@@ -99,22 +101,29 @@ getFullyQualifiedName(
99101
{
100102
temp.append(I.Name);
101103
}
102-
return temp;
103104
}
104105

105106
std::vector<SymbolID>
106107
getParents(Corpus const& C, const Info& I)
107108
{
108-
// AFREITAS: This function could eventually
109-
// return a view.
110109
std::vector<SymbolID> parents;
110+
std::size_t n = 0;
111111
auto curParent = I.Parent;
112112
while (curParent)
113113
{
114-
parents.push_back(curParent);
114+
++n;
115+
MRDOCS_ASSERT(C.find(curParent));
116+
curParent = C.get(curParent).Parent;
117+
}
118+
parents.reserve(n);
119+
parents.resize(n);
120+
curParent = I.Parent;
121+
while (curParent)
122+
{
123+
parents[--n] = curParent;
124+
MRDOCS_ASSERT(C.find(curParent));
115125
curParent = C.get(curParent).Parent;
116126
}
117-
std::ranges::reverse(parents);
118127
return parents;
119128
}
120129

src/lib/Lib/TagfileWriter.cpp

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -134,7 +134,7 @@ writeNamespace(
134134
{ "kind", "namespace" }
135135
});
136136

137-
tags_.write("name", corpus_->getFullyQualifiedName(I));
137+
tags_.write("name", corpus_->qualifiedName(I));
138138
tags_.write("filename", generateFilename(I));
139139

140140
// Write the class-like members of this namespace
@@ -144,7 +144,7 @@ writeNamespace(
144144
{
145145
tags_.write(
146146
"class",
147-
corpus_->getFullyQualifiedName(J),
147+
corpus_->qualifiedName(J),
148148
{{"kind", "class"}});
149149
}
150150
});
@@ -178,7 +178,7 @@ writeClassLike(
178178
tags_.open("compound", {
179179
{ "kind", "class" }
180180
});
181-
tags_.write("name", corpus_->getFullyQualifiedName(I));
181+
tags_.write("name", corpus_->qualifiedName(I));
182182
tags_.write("filename", generateFilename(I));
183183
if constexpr (T::isRecord())
184184
{

0 commit comments

Comments
 (0)