[Lldb-commits] [lldb] 2bea2d7 - [lldb] Refactor SBFileSpec::GetDirectory

Alex Langford via lldb-commits lldb-commits at lists.llvm.org
Tue May 2 10:01:48 PDT 2023


Author: Alex Langford
Date: 2023-05-02T10:01:36-07:00
New Revision: 2bea2d7b070dc5df723ce2b92dbc654b8bb1847e

URL: https://github.com/llvm/llvm-project/commit/2bea2d7b070dc5df723ce2b92dbc654b8bb1847e
DIFF: https://github.com/llvm/llvm-project/commit/2bea2d7b070dc5df723ce2b92dbc654b8bb1847e.diff

LOG: [lldb] Refactor SBFileSpec::GetDirectory

There's no reason to create an entire new filespec to mutate and grab
data from when we can just grab the data directly.

Differential Revision: https://reviews.llvm.org/D149625

Added: 
    

Modified: 
    lldb/source/API/SBFileSpec.cpp

Removed: 
    


################################################################################
diff  --git a/lldb/source/API/SBFileSpec.cpp b/lldb/source/API/SBFileSpec.cpp
index a7df9afc4b8e..8668b64b4ce7 100644
--- a/lldb/source/API/SBFileSpec.cpp
+++ b/lldb/source/API/SBFileSpec.cpp
@@ -114,9 +114,7 @@ const char *SBFileSpec::GetFilename() const {
 const char *SBFileSpec::GetDirectory() const {
   LLDB_INSTRUMENT_VA(this);
 
-  FileSpec directory{*m_opaque_up};
-  directory.ClearFilename();
-  return directory.GetPathAsConstString().GetCString();
+  return m_opaque_up->GetDirectory().GetCString();
 }
 
 void SBFileSpec::SetFilename(const char *filename) {


        


More information about the lldb-commits mailing list