[lldb] Refactor SBFileSpec::GetDirectory
authorAlex Langford <alangford@apple.com>
Tue, 2 May 2023 00:29:28 +0000 (17:29 -0700)
committerAlex Langford <alangford@apple.com>
Tue, 2 May 2023 17:01:36 +0000 (10:01 -0700)
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

lldb/source/API/SBFileSpec.cpp

index a7df9afc4b8eba4fb0a937c3f4445b3c078f4c6e..8668b64b4ce761634f2cbf9570802c00e53119cb 100644 (file)
@@ -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) {