https://github.com/felipepiovezan created https://github.com/llvm/llvm-project/pull/197405
This code path is particularly hot when logs are enabled. >From 65a4ea3fbb076b06b30f05c16a92a70aa332d17b Mon Sep 17 00:00:00 2001 From: Felipe de Azevedo Piovezan <[email protected]> Date: Wed, 13 May 2026 08:48:41 +0100 Subject: [PATCH] [LLDB][NFCI] Use resize_for_overwrite in VASprintf This code path is particularly hot when logs are enabled. --- lldb/source/Utility/VASprintf.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/lldb/source/Utility/VASprintf.cpp b/lldb/source/Utility/VASprintf.cpp index 5d361edf06e6c..ca3f953428b90 100644 --- a/lldb/source/Utility/VASprintf.cpp +++ b/lldb/source/Utility/VASprintf.cpp @@ -25,7 +25,7 @@ bool lldb_private::VASprintf(llvm::SmallVectorImpl<char> &buf, const char *fmt, va_list copy_args; va_copy(copy_args, args); - buf.resize(buf.capacity()); + buf.resize_for_overwrite(buf.capacity()); // Write up to `capacity` bytes, ignoring the current size. int length = ::vsnprintf(buf.data(), buf.size(), fmt, args); if (length < 0) { @@ -37,7 +37,7 @@ bool lldb_private::VASprintf(llvm::SmallVectorImpl<char> &buf, const char *fmt, if (size_t(length) >= buf.size()) { // The error formatted string didn't fit into our buffer, resize it to the // exact needed size, and retry - buf.resize(length + 1); + buf.resize_for_overwrite(length + 1); length = ::vsnprintf(buf.data(), buf.size(), fmt, copy_args); if (length < 0) { buf = error; _______________________________________________ lldb-commits mailing list [email protected] https://lists.llvm.org/cgi-bin/mailman/listinfo/lldb-commits
