MCPcopy Create free account
hub / github.com/Snapchat/Valdi / list

Method list

valdi/src/valdi/standalone_runtime/InMemoryDiskCache.cpp:37–59  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

35}
36
37std::vector<Path> InMemoryDiskCache::list(const Path& path) const {
38 auto absolutePath = toAbsolutePath(path);
39 std::vector<Path> output;
40 FlatSet<StringBox> seenEntries;
41 std::lock_guard<Mutex> guard(_cache->mutex);
42
43 auto& entries = _cache->entries;
44
45 for (const auto& it : entries) {
46 Path existingPath(it.first.toStringView());
47
48 if (existingPath.getComponents().size() > absolutePath.getComponents().size() &&
49 existingPath.startsWith(absolutePath)) {
50 auto newPath = absolutePath.appending(existingPath.getComponents()[absolutePath.getComponents().size()]);
51 auto inserted = seenEntries.insert(newPath.toStringBox());
52 if (inserted.second) {
53 output.emplace_back(std::move(newPath));
54 }
55 }
56 }
57
58 return output;
59}
60
61Path InMemoryDiskCache::toAbsolutePath(const Path& relativePath) const {
62 auto newPath = !relativePath.isAbsolute() ? _rootPath.appending(relativePath) : relativePath;

Callers 1

ShaderCacheMethod · 0.45

Calls 6

startsWithMethod · 0.80
insertMethod · 0.65
toStringViewMethod · 0.45
sizeMethod · 0.45
appendingMethod · 0.45
toStringBoxMethod · 0.45

Tested by

no test coverage detected