Skip to content

Commit

Permalink
Remove unnecessary assert from SourceManager when finding an existing…
Browse files Browse the repository at this point in the history
… cache entry for a new file insertion
  • Loading branch information
MikePopoloski committed Aug 2, 2023
1 parent 18e95b9 commit 8ac9549
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion source/text/SourceManager.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -484,8 +484,13 @@ SourceBuffer SourceManager::cacheBuffer(fs::path&& path, std::string&& pathStr,
auto fd = std::make_unique<FileData>(directory, std::move(name), std::move(buffer),
std::move(path));

// Note: it's possible that insertion here fails due to another thread
// racing against us to open and insert the same file. We do a lookup
// in the cache before proceeding to read the file but we drop the lock
// during the read. It's not actually a problem, we'll just use the data
// we already loaded (just like we had gotten a hit on the cache in the
// first place).
auto [it, inserted] = lookupCache.emplace(pathStr, std::pair{std::move(fd), std::error_code{}});
SLANG_ASSERT(inserted);

FileData* fdPtr = it->second.first.get();
return createBufferEntry(fdPtr, includedFrom, library, lock);
Expand Down

0 comments on commit 8ac9549

Please sign in to comment.