[Lldb-commits] [lldb] [lldb] Refactor string manipulation in Debugger.cpp (#91209) (PR #92565)

via lldb-commits lldb-commits at lists.llvm.org
Fri May 17 08:55:05 PDT 2024


https://github.com/aabhinavg created https://github.com/llvm/llvm-project/pull/92565

Summary of Changes:

Replaced the ineffective call to `substr` with a more efficient use of `resize` to truncate the string.
Adjusted the code to use 'resize' instead of 'substr' for better performance and readability.
Removed unwanted file from the previous commit.
Fixes: #91209 

>From 13fefb6846b6641900843c37746b03140063a955 Mon Sep 17 00:00:00 2001
From: aabhinavg <tiwariabhinavak at gmail.com>
Date: Fri, 17 May 2024 21:17:51 +0530
Subject: [PATCH] removed unwanted file

---
 lldb/source/Core/Debugger.cpp | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/lldb/source/Core/Debugger.cpp b/lldb/source/Core/Debugger.cpp
index 9951fbcd3e7c3..70303173925e3 100644
--- a/lldb/source/Core/Debugger.cpp
+++ b/lldb/source/Core/Debugger.cpp
@@ -2067,7 +2067,7 @@ void Debugger::HandleProgressEvent(const lldb::EventSP &event_sp) {
   const uint32_t term_width = GetTerminalWidth();
   const uint32_t ellipsis = 3;
   if (message.size() + ellipsis >= term_width)
-    message = message.substr(0, term_width - ellipsis);
+    message.resize(message.size() - ellipsis);
 
   const bool use_color = GetUseColor();
   llvm::StringRef ansi_prefix = GetShowProgressAnsiPrefix();



More information about the lldb-commits mailing list