mirror of
https://github.com/mozilla/gecko-dev.git
synced 2024-10-13 05:15:45 +00:00
Bug 1501903 - Cache the results of inThirdPartyPath. r=andi
The function is called a lot for the same paths and is rather costly, so cache the results for each path. Depends on D9758 Differential Revision: https://phabricator.services.mozilla.com/D9759 --HG-- extra : moz-landing-system : lando
This commit is contained in:
parent
371b282c0f
commit
3dabb0f250
@ -23,3 +23,5 @@ public:
|
||||
|
||||
static FrontendPluginRegistry::Add<MozCheckAction> X("moz-check",
|
||||
"check moz action");
|
||||
|
||||
DenseMap<unsigned, bool> InThirdPartyPathCache;
|
||||
|
@ -345,9 +345,17 @@ inline bool isPlacementNew(const CXXNewExpr *Expression) {
|
||||
return true;
|
||||
}
|
||||
|
||||
extern DenseMap<unsigned, bool> InThirdPartyPathCache;
|
||||
|
||||
inline bool inThirdPartyPath(SourceLocation Loc, const SourceManager &SM) {
|
||||
Loc = SM.getFileLoc(Loc);
|
||||
|
||||
unsigned id = SM.getFileID(Loc).getHashValue();
|
||||
auto pair = InThirdPartyPathCache.find(id);
|
||||
if (pair != InThirdPartyPathCache.end()) {
|
||||
return pair->second;
|
||||
}
|
||||
|
||||
SmallString<1024> RawFileName = SM.getFilename(Loc);
|
||||
llvm::sys::fs::make_absolute(RawFileName);
|
||||
SmallString<1024> FileName;
|
||||
@ -374,11 +382,13 @@ inline bool inThirdPartyPath(SourceLocation Loc, const SourceManager &SM) {
|
||||
|
||||
// We found a match!
|
||||
if (IThirdPartyB == ThirdPartyE) {
|
||||
InThirdPartyPathCache.insert(std::make_pair(id, true));
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
InThirdPartyPathCache.insert(std::make_pair(id, false));
|
||||
return false;
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user