Skip to content

Commit 882fa81

Browse files
committed
Add cache for fullyQualifiedName
1 parent f7a3adf commit 882fa81

File tree

1 file changed

+8
-0
lines changed

1 file changed

+8
-0
lines changed

src/cppconv/cppsemantic.d

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -331,6 +331,7 @@ class Semantic
331331
}
332332

333333
bool[QualType] hasMutableIndirectionCache;
334+
string[Declaration] fullyQualifiedNameCache;
334335
}
335336

336337
struct SemanticRunInfo
@@ -2435,6 +2436,9 @@ template iterateTreeConditions(alias F)
24352436

24362437
string fullyQualifiedName(Semantic semantic, Declaration d)
24372438
{
2439+
auto inCache = d in semantic.fullyQualifiedNameCache;
2440+
if (inCache)
2441+
return *inCache;
24382442
Appender!string app;
24392443
void visitScope(Scope s)
24402444
{
@@ -2484,7 +2488,11 @@ string fullyQualifiedName(Semantic semantic, Declaration d)
24842488
}
24852489
visitScope(s);
24862490
if (app.data.length == 0)
2491+
{
2492+
semantic.fullyQualifiedNameCache[d] = d.name;
24872493
return d.name;
2494+
}
24882495
app.put(d.name);
2496+
semantic.fullyQualifiedNameCache[d] = app.data;
24892497
return app.data;
24902498
}

0 commit comments

Comments
 (0)