Core: RemoveIf optimised

git-svn-id: svn://ultimatepp.org/upp/trunk@15327 f0d560ea-af0d-0410-9eb7-867de7ffcac7
This commit is contained in:
cxl 2020-10-30 10:45:21 +00:00
parent bfb42d1fd7
commit c9db2e45d3

View file

@ -272,7 +272,15 @@ template <class Condition>
void Vector<T>::RemoveIf(Condition c)
{
int ti = 0;
for(int i = 0; i < items; i++)
int i = 0;
for(; i < items; i++) { // run to the first element without moving
if(c(i)) {
(vector + i++)->~T();
break;
}
ti++;
}
for(; i < items; i++)
if(c(i))
(vector + i)->~T();
else