jkorous added a comment. IIUC the issue is that `SourceManager::translateFile()` basically consists of two blocks of code:
// First, check the main file ID, since it is common to look for a // location in the main file. if (MainFileID.isValid()) { bool Invalid = false; const SLocEntry &MainSLoc = getSLocEntry(MainFileID, &Invalid); if (Invalid) return FileID(); if (MainSLoc.isFile()) { const ContentCache *MainContentCache = MainSLoc.getFile().getContentCache(); if (MainContentCache && MainContentCache->OrigEntry == SourceFile) return MainFileID; } } and // The location we're looking for isn't in the main file; look // through all of the local source locations. ... The comments suggest that the first block is a heuristic related to our case and the second block I would assume being the expensive part. `SourceManager::getFileEntryRefForID` implementation seems similar to the first block. It makes sense to me to avoid the expensive search. I'm just wondering - how much speedup do we get with caching the value? CHANGES SINCE LAST ACTION https://reviews.llvm.org/D79834/new/ https://reviews.llvm.org/D79834 _______________________________________________ cfe-commits mailing list cfe-commits@lists.llvm.org https://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits