[Lldb-commits] [lldb] r371836 - [lldb][NFC] Simplify Args::ReplaceArgumentAtIndex

Raphael Isemann via lldb-commits lldb-commits at lists.llvm.org
Fri Sep 13 03:41:29 PDT 2019


Author: teemperor
Date: Fri Sep 13 03:41:29 2019
New Revision: 371836

URL: http://llvm.org/viewvc/llvm-project?rev=371836&view=rev
Log:
[lldb][NFC] Simplify Args::ReplaceArgumentAtIndex

This code is not on any performance critical path that would
justify this shortening optimization. It also makes it possible
to turn 'ref' into a function (as this is the only place where
we modify this ArgEntry member).

Modified:
    lldb/trunk/source/Utility/Args.cpp

Modified: lldb/trunk/source/Utility/Args.cpp
URL: http://llvm.org/viewvc/llvm-project/lldb/trunk/source/Utility/Args.cpp?rev=371836&r1=371835&r2=371836&view=diff
==============================================================================
--- lldb/trunk/source/Utility/Args.cpp (original)
+++ lldb/trunk/source/Utility/Args.cpp Fri Sep 13 03:41:29 2019
@@ -336,15 +336,8 @@ void Args::ReplaceArgumentAtIndex(size_t
   if (idx >= m_entries.size())
     return;
 
-  if (arg_str.size() > m_entries[idx].ref.size()) {
-    m_entries[idx] = ArgEntry(arg_str, quote_char);
-    m_argv[idx] = m_entries[idx].data();
-  } else {
-    const char *src_data = arg_str.data() ? arg_str.data() : "";
-    ::memcpy(m_entries[idx].data(), src_data, arg_str.size());
-    m_entries[idx].ptr[arg_str.size()] = 0;
-    m_entries[idx].ref = m_entries[idx].ref.take_front(arg_str.size());
-  }
+  m_entries[idx] = ArgEntry(arg_str, quote_char);
+  m_argv[idx] = m_entries[idx].data();
 }
 
 void Args::DeleteArgumentAtIndex(size_t idx) {




More information about the lldb-commits mailing list