Skip to content

Commit 8ec166c

Browse files
ttsugriyfacebook-github-bot
authored andcommitted
Simplify non-optimal points removal.
Summary: This version is more concise and doesn't need a new scope to reduce visibility of local variable `i`. Created from CodeHub with https://fburl.com/edit-in-codehub Reviewed By: mdouze Differential Revision: D46431189 fbshipit-source-id: 5bbe8df6014d8e25aeb8d5d15145b703e9651327
1 parent f82298f commit 8ec166c

File tree

1 file changed

+4
-6
lines changed

1 file changed

+4
-6
lines changed

faiss/AutoTune.cpp

Lines changed: 4 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -152,12 +152,10 @@ bool OperatingPoints::add(
152152
return false;
153153
}
154154
}
155-
{ // remove non-optimal points from array
156-
int i = a.size() - 1;
157-
while (i > 0) {
158-
if (a[i].t < a[i - 1].t)
159-
a.erase(a.begin() + (i - 1));
160-
i--;
155+
// remove non-optimal points from array
156+
for (int i = a.size() - 1; i > 0; --i) {
157+
if (a[i].t < a[i - 1].t) {
158+
a.erase(a.begin() + (i - 1));
161159
}
162160
}
163161
return true;

0 commit comments

Comments
 (0)