Skip to content

Commit

Permalink
Optimize IsWrapper
Browse files Browse the repository at this point in the history
The getNameAsString interface causes a lot of temporary allocations.
The analysis if a decl is a cling-style wrapper can work only on a
simple declarations on the global scope.

This patch filters out complex declarations (eg in namespaces) and
checks only the identifier content.

The patch reduces the memory footprint difference shown in root-project/root#3012.
  • Loading branch information
vgvassilev authored and SFT committed Mar 25, 2019
1 parent b639a0d commit eab5eca
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions lib/Utils/AST.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -67,9 +67,10 @@ namespace utils {
bool Analyze::IsWrapper(const FunctionDecl* ND) {
if (!ND)
return false;
if (!ND->getDeclName().isIdentifier())
return false;

return StringRef(ND->getNameAsString())
.startswith(Synthesize::UniquePrefix);
return ND->getName().startswith(Synthesize::UniquePrefix);
}

void Analyze::maybeMangleDeclName(const GlobalDecl& GD,
Expand Down

0 comments on commit eab5eca

Please sign in to comment.