From cbd61b54f9e74dafab0ebbd3d79bac93d188f38f Mon Sep 17 00:00:00 2001 From: clinton Date: Tue, 18 Nov 2008 21:41:48 +0000 Subject: [PATCH] Slightly better Utils::push_sorted No need to special case the not found case --- source/Utils.H | 11 ++++------- 1 file changed, 4 insertions(+), 7 deletions(-) diff --git a/source/Utils.H b/source/Utils.H index 0c5c008..46c0496 100644 --- a/source/Utils.H +++ b/source/Utils.H @@ -87,13 +87,10 @@ namespace Utils { template void push_sorted (std::list & storage, T item, C compare) { - typename std::list::iterator it = - std::find_if (storage.begin (), storage.end (), - std::bind1st (compare, item)); - if (it != storage.end ()) - storage.insert (it, item); - else - storage.push_back (item); + storage.insert (std::find_if (storage.begin (), storage.end (), + std::bind1st (compare, item)), + item); + } } -- 2.20.1