From 04dd1447eeaba87d8c12c64c4308c3b1f6e1adb3 Mon Sep 17 00:00:00 2001 From: Michele Caini Date: Mon, 17 Jun 2019 16:14:20 +0200 Subject: [PATCH] minor changes --- src/entt/core/algorithm.hpp | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/src/entt/core/algorithm.hpp b/src/entt/core/algorithm.hpp index 5936df91a..9c4513d5d 100644 --- a/src/entt/core/algorithm.hpp +++ b/src/entt/core/algorithm.hpp @@ -54,18 +54,16 @@ struct insertion_sort { */ template> void operator()(It first, It last, Compare compare = Compare{}) const { - if(first != last) { - auto it = first + 1; + if(first < last) { + for(auto it = first+1; it < last; ++it) { + auto value = std::move(*it); + auto pre = it; - while(it != last) { - auto pre = it++; - auto value = *pre; - - for(; pre != first && compare(value, *(pre-1)); --pre) { - *pre = *(pre-1); + for(; pre > first && compare(value, *(pre-1)); --pre) { + *pre = std::move(*(pre-1)); } - *pre = value; + *pre = std::move(value); } } }