-
Notifications
You must be signed in to change notification settings - Fork 10.5k
[NFC] Replace uses of find(x) != end() idiom with contains(x) for StringRef and Set-like types #35229
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
[NFC] Replace uses of find(x) != end() idiom with contains(x) for StringRef and Set-like types #35229
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -142,8 +142,8 @@ static bool canonicalizeInputFunction(Function &F, ARCEntryPointBuilder &B, | |
// Have not encountered a strong retain/release. keep it in the | ||
// unknown retain/release list for now. It might get replaced | ||
// later. | ||
if (NativeRefs.find(ArgVal) == NativeRefs.end()) { | ||
UnknownObjectRetains[ArgVal].push_back(&CI); | ||
if (!NativeRefs.contains(ArgVal)) { | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. It seems like the change to There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Yeah, seems like it hasn't ... I would say that use There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Hmm, I seem to have made a mistake here. I looked at the We can wait for a couple of weeks; I'll ping this PR when we have the rebranch so we can run tests and land the change. I don't think cherry-picking changes onto other branches is the right fix here, as that might lead to more merge conflicts. |
||
UnknownObjectRetains[ArgVal].push_back(&CI); | ||
} else { | ||
B.setInsertPoint(&CI); | ||
B.createRetain(ArgVal, &CI); | ||
|
@@ -189,7 +189,7 @@ static bool canonicalizeInputFunction(Function &F, ARCEntryPointBuilder &B, | |
// Have not encountered a strong retain/release. keep it in the | ||
// unknown retain/release list for now. It might get replaced | ||
// later. | ||
if (NativeRefs.find(ArgVal) == NativeRefs.end()) { | ||
if (!NativeRefs.contains(ArgVal)) { | ||
UnknownObjectReleases[ArgVal].push_back(&CI); | ||
} else { | ||
B.setInsertPoint(&CI); | ||
|
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -163,12 +163,11 @@ static bool doPrintBefore(SILTransform *T, SILFunction *F) { | |
return false; | ||
|
||
if (!SILPrintOnlyFuns.empty() && F && | ||
F->getName().find(SILPrintOnlyFuns, 0) == StringRef::npos) | ||
!F->getName().contains(SILPrintOnlyFuns)) | ||
return false; | ||
|
||
auto MatchFun = [&](const std::string &Str) -> bool { | ||
return T->getTag().find(Str) != StringRef::npos | ||
|| T->getID().find(Str) != StringRef::npos; | ||
return T->getTag().contains(Str) || T->getID().contains(Str); | ||
}; | ||
|
||
if (SILPrintBefore.end() != | ||
|
@@ -188,12 +187,11 @@ static bool doPrintAfter(SILTransform *T, SILFunction *F, bool Default) { | |
return false; | ||
|
||
if (!SILPrintOnlyFuns.empty() && F && | ||
F->getName().find(SILPrintOnlyFuns, 0) == StringRef::npos) | ||
!F->getName().contains(SILPrintOnlyFuns)) | ||
return false; | ||
|
||
auto MatchFun = [&](const std::string &Str) -> bool { | ||
return T->getTag().find(Str) != StringRef::npos | ||
|| T->getID().find(Str) != StringRef::npos; | ||
return T->getTag().contains(Str) || T->getID().contains(Str); | ||
}; | ||
|
||
if (SILPrintAfter.end() != | ||
|
@@ -215,8 +213,7 @@ static bool isDisabled(SILTransform *T, SILFunction *F = nullptr) { | |
return false; | ||
|
||
for (const std::string &NamePattern : SILDisablePass) { | ||
if (T->getTag().find(NamePattern) != StringRef::npos | ||
|| T->getID().find(NamePattern) != StringRef::npos) { | ||
if (T->getTag().contains(NamePattern) || T->getID().contains(NamePattern)) { | ||
return true; | ||
} | ||
} | ||
|
@@ -233,8 +230,7 @@ static void printModule(SILModule *Mod, bool EmitVerboseSIL) { | |
std::find(SILPrintOnlyFun.begin(), SILPrintOnlyFun.end(), F.getName())) | ||
F.dump(EmitVerboseSIL); | ||
|
||
if (!SILPrintOnlyFuns.empty() && | ||
F.getName().find(SILPrintOnlyFuns, 0) != StringRef::npos) | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. A note for myself. Whats with the 0? (I am doing a surface level review scan now). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. @mininny I looked in StringRef.h. Looks like the 0 is a default argument to find that says start checking at the beginning. (Just answering my own question). |
||
if (!SILPrintOnlyFuns.empty() && F.getName().contains(SILPrintOnlyFuns)) | ||
F.dump(EmitVerboseSIL); | ||
} | ||
} | ||
|
@@ -429,8 +425,7 @@ void SILPassManager::runPassOnFunction(unsigned TransIdx, SILFunction *F) { | |
CurrentPassHasInvalidated = false; | ||
|
||
auto MatchFun = [&](const std::string &Str) -> bool { | ||
return SFT->getTag().find(Str) != StringRef::npos || | ||
SFT->getID().find(Str) != StringRef::npos; | ||
return SFT->getTag().contains(Str) || SFT->getID().contains(Str); | ||
}; | ||
if ((SILVerifyBeforePass.end() != std::find_if(SILVerifyBeforePass.begin(), | ||
SILVerifyBeforePass.end(), | ||
|
@@ -597,8 +592,7 @@ void SILPassManager::runModulePass(unsigned TransIdx) { | |
} | ||
|
||
auto MatchFun = [&](const std::string &Str) -> bool { | ||
return SMT->getTag().find(Str) != StringRef::npos || | ||
SMT->getID().find(Str) != StringRef::npos; | ||
return SMT->getTag().contains(Str) || SMT->getID().contains(Str); | ||
}; | ||
if ((SILVerifyBeforePass.end() != std::find_if(SILVerifyBeforePass.begin(), | ||
SILVerifyBeforePass.end(), | ||
|
Uh oh!
There was an error while loading. Please reload this page.