[Lldb-commits] [PATCH] D150914: [lldb][NFCI] Pre-allocate storage in ObjCLanguage::MethodName::GetFullNameWithoutCategory
Alex Langford via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Thu May 18 15:35:30 PDT 2023
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 += '+';
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D150914.523585.patch
Type: text/x-patch
Size: 748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230518/85543f99/attachment.bin>
More information about the lldb-commits
mailing list