diff options
author | Maksim Denisov <denisov.maksim@huawei.com> | 2024-05-02 12:27:39 +0200 |
---|---|---|
committer | Maksim Denisov <denisov.maksim@huawei.com> | 2024-05-02 12:49:57 +0200 |
commit | 467b377f3ea1026f0450aaac3b093d3e267c286e (patch) | |
tree | 85e9130ba76614220af989022716b045e3d7c126 /src/buildtool/file_system/file_storage.hpp | |
parent | e40439b4df897b44ef38601475ee6b9a50002741 (diff) | |
download | justbuild-467b377f3ea1026f0450aaac3b093d3e267c286e.tar.gz |
Use a named constant length for FileStorage directory names
Diffstat (limited to 'src/buildtool/file_system/file_storage.hpp')
-rw-r--r-- | src/buildtool/file_system/file_storage.hpp | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/src/buildtool/file_system/file_storage.hpp b/src/buildtool/file_system/file_storage.hpp index 178fa7da..fefd22a7 100644 --- a/src/buildtool/file_system/file_storage.hpp +++ b/src/buildtool/file_system/file_storage.hpp @@ -35,6 +35,11 @@ enum class StoreMode { LastWins }; +struct FileStorageData final { + /// Length of a subdirectory name. + static constexpr size_t kDirectoryNameLength = 2; +}; + template <ObjectType kType, StoreMode kMode, bool kSetEpochTime, @@ -71,7 +76,10 @@ class FileStorage { /// \returns The sharded file path. [[nodiscard]] auto GetPath(std::string const& id) const noexcept -> std::filesystem::path { - return storage_root_ / id.substr(0, 2) / id.substr(2, id.size() - 2); + return storage_root_ / + id.substr(0, FileStorageData::kDirectoryNameLength) / + id.substr(FileStorageData::kDirectoryNameLength, + id.size() - FileStorageData::kDirectoryNameLength); } [[nodiscard]] auto StorageRoot() const noexcept |