bulbazord created this revision. bulbazord added a reviewer: aprantl. Herald added a project: All. bulbazord requested review of this revision. Herald added a project: LLDB. Herald added a subscriber: lldb-commits.
The size of a full ObjC MethodName can vary somewhat, but it is computable ahead of time. Using a reasonably sized ObjC application, this actually improves the time it takes to initialize symbol indexes for ObjC names ever so slightly. Additionally, I found that the variability in time also was improved considerably. Repository: rG LLVM Github Monorepo https://reviews.llvm.org/D150914 Files: lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp =================================================================== --- lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -152,7 +152,15 @@ llvm::StringRef class_name = GetClassName(); llvm::StringRef selector_name = GetSelector(); + + // Compute the total size to avoid reallocations + // class name + selector name + '[' + ' ' + ']' + size_t total_size = class_name.size() + selector_name.size() + 3; + if (m_type != eTypeUnspecified) + total_size++; // For + or - + std::string name_sans_category; + name_sans_category.reserve(total_size); if (m_type == eTypeClassMethod) name_sans_category += '+';
Index: lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp =================================================================== --- lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp +++ lldb/source/Plugins/Language/ObjC/ObjCLanguage.cpp @@ -152,7 +152,15 @@ llvm::StringRef class_name = GetClassName(); llvm::StringRef selector_name = GetSelector(); + + // Compute the total size to avoid reallocations + // class name + selector name + '[' + ' ' + ']' + size_t total_size = class_name.size() + selector_name.size() + 3; + if (m_type != eTypeUnspecified) + total_size++; // For + or - + std::string name_sans_category; + name_sans_category.reserve(total_size); if (m_type == eTypeClassMethod) name_sans_category += '+';
_______________________________________________ lldb-commits mailing list lldb-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits