-
Notifications
You must be signed in to change notification settings - Fork 10.8k
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][VPlan] Simplify VPValue::removeUser #74708
Conversation
@llvm/pr-subscribers-llvm-transforms Author: Shao-Ce SUN (sunshaoce) ChangesI think we don't need to use lambda, and we can end the loop in advance like this. Full diff: https://github.com/llvm/llvm-project/pull/74708.diff 1 Files Affected:
diff --git a/llvm/lib/Transforms/Vectorize/VPlanValue.h b/llvm/lib/Transforms/Vectorize/VPlanValue.h
index ac2883b30dc8c..14634dc31878f 100644
--- a/llvm/lib/Transforms/Vectorize/VPlanValue.h
+++ b/llvm/lib/Transforms/Vectorize/VPlanValue.h
@@ -121,18 +121,14 @@ class VPValue {
/// Remove a single \p User from the list of users.
void removeUser(VPUser &User) {
- bool Found = false;
// The same user can be added multiple times, e.g. because the same VPValue
// is used twice by the same VPUser. Remove a single one.
- erase_if(Users, [&User, &Found](VPUser *Other) {
- if (Found)
- return false;
- if (Other == &User) {
- Found = true;
- return true;
+ for (const auto &U : Users) {
+ if (U == &User) {
+ Users.erase(&U);
+ return;
}
- return false;
- });
+ }
}
typedef SmallVectorImpl<VPUser *>::iterator user_iterator;
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
LGTM, thanks.
Please see the inline comment before merging and also adjust the commit messages to be definitive, i.e. drop It think
and adjust to say hat this is now using find + erase; there's no more explicit loop.
I think we don't need to use lambda, and we can end the loop in advance like this.