(svn r13275) -Fix: sort lists with 2 items, too
authorsmatz
Mon, 26 May 2008 21:08:03 +0000
changeset 9371 da6ac5609943
parent 9370 7e64238f2dbd
child 9372 2ee65824ee6d
(svn r13275) -Fix: sort lists with 2 items, too
-Fix: reset VL_RESORT and resort timer even when no sort was needed
src/sortlist_type.h
--- a/src/sortlist_type.h	Mon May 26 20:20:38 2008 +0000
+++ b/src/sortlist_type.h	Mon May 26 21:08:03 2008 +0000
@@ -40,7 +40,7 @@
 	 */
 	bool IsSortable() const
 	{
-		return (this->data != NULL && this->items > 2);
+		return (this->data != NULL && this->items >= 2);
 	}
 
 	/**
@@ -178,12 +178,16 @@
 	 * */
 	FORCEINLINE void Sort(SortFunction compare)
 	{
+		/* Do not sort if the resort bit is not set */
+		if (!HASBITS(this->flags, VL_RESORT)) return;
+
+		CLRBITS(this->flags, VL_RESORT);
+
+		this->ResetResortTimer();
+
 		/* Do not sort when the list is not sortable */
 		if (!this->IsSortable()) return;
 
-		/* Do not sort if the resort bit is not set */
-		if (!HASBITS(this->flags, VL_RESORT)) return;
-
 		T *a = this->data;
 		T *b = a + 1;
 
@@ -213,10 +217,6 @@
 				}
 			}
 		}
-
-		this->ResetResortTimer();
-
-		CLRBITS(this->flags, VL_RESORT);
 	}
 
 	/**