[Lldb-commits] [PATCH] D151765: [lldb] Introduce the FileSpecBuilder abstraction
Alex Langford via Phabricator via lldb-commits
lldb-commits at lists.llvm.org
Tue May 30 18:14:18 PDT 2023
bulbazord created this revision.
bulbazord added reviewers: JDevlieghere, mib, jingham, jasonmolenda, clayborg.
Herald added a project: All.
bulbazord requested review of this revision.
Herald added a project: LLDB.
Herald added a subscriber: lldb-commits.
Mutating a FileSpec is quite expensive. Every time you add or remove a
component of a path, we need to re-parse the entire path and insert a
new directory and filename into the ConstString StringPool. In many
cases, we take an existing FilePath and slowly morph it into the one we
want to actually use.
In order to improve performance, I want to introduce a new abstraction
called the `FileSpecBuilder`. The idea is that it maintains a
SmallString to store the entire path and a path style. It uses llvm's
path manipulation code to quickly append and remove things so we don't
have to re-parse the path every single time. When you're done
manipulating paths and want a FileSpec for sure, you can invoke
`FileSpecBuilder::CreateFileSpec` to create a new FileSpec, only parsing
the path once.
This patch primarily is to gather feedback about the idea. I wanted to
keep this patch small and targeted to get specific feedback, and for
that reason I avoided doing any kind of refactoring as most changes will
be quite invasive. Instead I opted to add unit tests to show how I want
FileSpecBuilder to be used in code. If this abstraction goes into LLDB,
I will refactor every place where we mutate a FileSpec until
FileSpecBuilder is the default way of manipulating paths.
For further motivation of this change, please see:
https://reviews.llvm.org/D149096
Repository:
rG LLVM Github Monorepo
https://reviews.llvm.org/D151765
Files:
lldb/include/lldb/Utility/FileSpecBuilder.h
lldb/source/Utility/CMakeLists.txt
lldb/source/Utility/FileSpecBuilder.cpp
lldb/unittests/Utility/FileSpecBuilderTest.cpp
-------------- next part --------------
A non-text attachment was scrubbed...
Name: D151765.526861.patch
Type: text/x-patch
Size: 10525 bytes
Desc: not available
URL: <http://lists.llvm.org/pipermail/lldb-commits/attachments/20230531/e341f7c2/attachment.bin>
More information about the lldb-commits
mailing list