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

Function readFileCached

tsn/src/test262/runner/main.cpp:137–153  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

135};
136
137Result<std::string> readFileCached(const fs::path& file) {
138 static std::map<std::string, std::string> fileCache;
139 auto findItr = fileCache.find(file);
140 if (findItr != fileCache.end()) {
141 return findItr->second;
142 }
143
144 auto loadResult = DiskUtils::load(Path(file.string()));
145 if (!loadResult) {
146 TEST262_LOG(cerr, "Failed to load {} with error {}", file.string(), loadResult.error().getMessage());
147 return loadResult.error();
148 }
149 const auto loadData = loadResult.moveValue();
150
151 fileCache[file] = loadData.asStringView();
152 return fileCache[file];
153}
154
155enum class ExecutionResult {
156 RunWithPass,

Callers 1

evaluateTestCaseInternalFunction · 0.85

Calls 8

loadFunction · 0.85
asStringViewMethod · 0.80
endMethod · 0.65
getMessageMethod · 0.65
errorMethod · 0.65
PathClass · 0.50
findMethod · 0.45
stringMethod · 0.45

Tested by

no test coverage detected