aboutsummaryrefslogtreecommitdiff
path: root/lldb/source/Host/common/FileSystem.cpp
diff options
context:
space:
mode:
authorJonas Devlieghere <jonas@devlieghere.com>2023-06-26 10:45:23 -0700
committerJonas Devlieghere <jonas@devlieghere.com>2023-06-27 14:19:02 -0700
commitca7914564e676fe52fa80049d9c6932653522424 (patch)
tree5a74a5584387d140afdc66f6f3265411960669d8 /lldb/source/Host/common/FileSystem.cpp
parent3a4e9f7ae50980ce8f103cbe86d24c574c8c6cac (diff)
downloadllvm-ca7914564e676fe52fa80049d9c6932653522424.zip
llvm-ca7914564e676fe52fa80049d9c6932653522424.tar.gz
llvm-ca7914564e676fe52fa80049d9c6932653522424.tar.bz2
[lldb] Avoid FileSystem::Resolve for cached files in the SourceManager
Currently, source files are cached by their resolved path. This means that before we can query the cache, we potentially have to resolve the path, which can be slow. This patch avoids the call to FileSystem::Resolve by caching both the resolved and unresolved path. We now only resolve the path once when we create and cache a new file. rdar://110787562 Differential revision: https://reviews.llvm.org/D153726
Diffstat (limited to 'lldb/source/Host/common/FileSystem.cpp')
-rw-r--r--lldb/source/Host/common/FileSystem.cpp18
1 files changed, 3 insertions, 15 deletions
diff --git a/lldb/source/Host/common/FileSystem.cpp b/lldb/source/Host/common/FileSystem.cpp
index 1fe4e8f..52227a9 100644
--- a/lldb/source/Host/common/FileSystem.cpp
+++ b/lldb/source/Host/common/FileSystem.cpp
@@ -9,8 +9,6 @@
#include "lldb/Host/FileSystem.h"
#include "lldb/Utility/DataBufferLLVM.h"
-#include "lldb/Utility/LLDBAssert.h"
-#include "lldb/Utility/TildeExpressionResolver.h"
#include "llvm/Support/Errc.h"
#include "llvm/Support/Errno.h"
@@ -46,16 +44,6 @@ using namespace llvm;
FileSystem &FileSystem::Instance() { return *InstanceImpl(); }
-void FileSystem::Initialize() {
- lldbassert(!InstanceImpl() && "Already initialized.");
- InstanceImpl().emplace();
-}
-
-void FileSystem::Initialize(IntrusiveRefCntPtr<vfs::FileSystem> fs) {
- lldbassert(!InstanceImpl() && "Already initialized.");
- InstanceImpl().emplace(fs);
-}
-
void FileSystem::Terminate() {
lldbassert(InstanceImpl() && "Already terminated.");
InstanceImpl().reset();
@@ -239,9 +227,9 @@ void FileSystem::Resolve(SmallVectorImpl<char> &path) {
// Resolve tilde in path.
SmallString<128> resolved(path.begin(), path.end());
- StandardTildeExpressionResolver Resolver;
- Resolver.ResolveFullPath(llvm::StringRef(path.begin(), path.size()),
- resolved);
+ assert(m_tilde_resolver && "must initialize tilde resolver in constructor");
+ m_tilde_resolver->ResolveFullPath(llvm::StringRef(path.begin(), path.size()),
+ resolved);
// Try making the path absolute if it exists.
SmallString<128> absolute(resolved.begin(), resolved.end());