From eab5eca3ea4b373d0e54766b9d71e30c76d3e514 Mon Sep 17 00:00:00 2001 From: Vassil Vassilev Date: Mon, 25 Mar 2019 17:39:32 +0200 Subject: [PATCH] Optimize IsWrapper 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. --- lib/Utils/AST.cpp | 5 +++-- 1 file changed, 3 insertions(+), 2 deletions(-) diff --git a/lib/Utils/AST.cpp b/lib/Utils/AST.cpp index cad23f6a56..783d9e0ef3 100644 --- a/lib/Utils/AST.cpp +++ b/lib/Utils/AST.cpp @@ -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,