Bug 1163029 - Use NamedDecl::getName instead of expensive NamedDecl::getNameAsString. r=ehsan
authorBirunthan Mohanathas <birunthan@mohanathas.com>
Fri, 08 May 2015 09:29:11 -0700
changeset 243389 107ff1a3cebd31da16c14b6bb69d3751bea2f4a4
parent 243388 8bcd2e511413b074af96c3a1727d35d384e8f804
child 243390 4ff686c997507c045be0a5b058ec22bac9897fcd
push id28738
push usercbook@mozilla.com
push dateTue, 12 May 2015 14:11:31 +0000
treeherdermozilla-central@bedce1b405a3 [default view] [failures only]
perfherder[talos] [build metrics] [platform microbench] (compared to previous push)
reviewersehsan
bugs1163029
milestone40.0a1
first release with
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
last release without
nightly linux32
nightly linux64
nightly mac
nightly win32
nightly win64
Bug 1163029 - Use NamedDecl::getName instead of expensive NamedDecl::getNameAsString. r=ehsan
build/clang-plugin/clang-plugin.cpp
--- a/build/clang-plugin/clang-plugin.cpp
+++ b/build/clang-plugin/clang-plugin.cpp
@@ -416,17 +416,17 @@ bool classHasAddRefRelease(const CXXReco
   if (it != refCountedClasses.end()) {
     return it->second.second;
   }
 
   bool seenAddRef = false;
   bool seenRelease = false;
   for (CXXRecordDecl::method_iterator method = D->method_begin();
        method != D->method_end(); ++method) {
-    std::string name = method->getNameAsString();
+    const auto &name = method->getName();
     if (name == "AddRef") {
       seenAddRef = true;
     } else if (name == "Release") {
       seenRelease = true;
     }
   }
   refCountedClasses[D] = std::make_pair(D, seenAddRef && seenRelease);
   return seenAddRef && seenRelease;
@@ -583,17 +583,17 @@ AST_MATCHER(BinaryOperator, isInSkScalar
   return llvm::sys::path::rbegin(FileName)->equals("SkScalar.h");
 }
 
 /// This matcher will match all accesses to AddRef or Release methods.
 AST_MATCHER(MemberExpr, isAddRefOrRelease) {
   ValueDecl *Member = Node.getMemberDecl();
   CXXMethodDecl *Method = dyn_cast<CXXMethodDecl>(Member);
   if (Method) {
-    std::string Name = Method->getNameAsString();
+    const auto &Name = Method->getName();
     return Name == "AddRef" || Name == "Release";
   }
   return false;
 }
 
 /// This matcher will select classes which are refcounted.
 AST_MATCHER(QualType, isRefCounted) {
   return isClassRefCounted(Node);