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

Method lockFreeLoadEntriesIfNeeded

valdi/src/valdi/runtime/Resources/Bundle.cpp:113–133  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

111}
112
113Result<Void> Bundle::lockFreeLoadEntriesIfNeeded() {
114 if (_loadedEntries) {
115 return Void();
116 }
117
118 if (_decompressedBundle == nullptr) {
119 return Valdi::Error(STRING_FORMAT("Bundle '{}' was not loaded", _name));
120 }
121
122 _loadedEntries = true;
123
124 for (const auto& entryPath : _decompressedBundle->getAllEntryPaths()) {
125 if (_entryByPath.find(entryPath) == _entryByPath.end()) {
126 auto entry = _decompressedBundle->getEntry(entryPath);
127 _entryByPath[entryPath] = BytesView(_decompressedBundle, entry->data, entry->size);
128 _allEntryPaths.emplace_back(entryPath);
129 }
130 }
131
132 return Void();
133}
134
135Result<BytesView> Bundle::getEntry(const StringBox& path) {
136 std::lock_guard<std::recursive_mutex> guard(_mutex);

Callers

nothing calls this directly

Calls 7

getAllEntryPathsMethod · 0.80
endMethod · 0.65
VoidClass · 0.50
ErrorInterface · 0.50
BytesViewClass · 0.50
findMethod · 0.45
getEntryMethod · 0.45

Tested by

no test coverage detected