Improve rstl::__insertion_sort, use in CScriptSpecialFunction

Former-commit-id: 714e3dea7e
This commit is contained in:
Henrique Gemignani Passos Lima
2022-11-27 15:23:54 +02:00
parent 4bade5e25e
commit b97f9c56de
3 changed files with 11 additions and 18 deletions

View File

@@ -40,13 +40,10 @@ void __insertion_sort(It first, It last, Cmp cmp) {
typename iterator_traits< It >::value_type value = *next;
It t1 = next;
It t2 = next;
while (first < t1 && cmp(value, *(t2 - 1))) {
*t1 = *(t2 - 1);
for (It t2 = next - 1; first < t1 && cmp(value, *t2); --t2) {
*t1 = *t2;
--t1;
--t2;
}
*t1 = value;
}
}