[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 16:23:36 PDT 2023
This revision was automatically updated to reflect the committed changes.
Closed by commit rGe8d3f061ba41: [lldb][NFCI] Pre-allocate storage in ObjCLanguage::MethodName… (authored by bulbazord).
Repository:
rG LLVM Github Monorepo
CHANGES SINCE LAST ACTION
https://reviews.llvm.org/D150914/new/
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.523600.patch
Type: text/x-patch
Size: 748 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230518/88dca1a5/attachment-0001.bin>
More information about the lldb-commits
mailing list