From cbaa100229b5001f41f13912fba2125213ab3d1f Mon Sep 17 00:00:00 2001 From: Kevin Smith Date: Mon, 5 Oct 2009 21:17:27 +0100 Subject: Early terminate completed bubblesorts in the roster diff --git a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp index 487dbb6..b237929 100644 --- a/Swift/QtUI/Roster/QtTreeWidgetItem.cpp +++ b/Swift/QtUI/Roster/QtTreeWidgetItem.cpp @@ -121,9 +121,12 @@ void QtTreeWidgetItem::removeChild(QtTreeWidgetItem* child) { } void bubbleSort(QList& list) { - for (int i = 0; i < list.size(); i++) { + bool done = true; + for (int i = 0; i < list.size() - 1 && !done; i++) { + done = true; for (int j = i + 1; j < list.size(); j++) { if (*(list[j]) < *(list[j - 1])) { + done = false; QtTreeWidgetItem* lower = list[j]; list[j] = list[j - 1]; list[j - 1] = lower; @@ -135,7 +138,7 @@ void bubbleSort(QList& list) { void QtTreeWidgetItem::handleChanged(QtTreeWidgetItem* child) { /*We don't use the much faster qStableSort because it causes changed(child) and all sorts of nasty recursion*/ //qStableSort(children_.begin(), children_.end(), itemLessThan); - //bubbleSort(children_); + bubbleSort(children_); shownChildren_.clear(); for (int i = 0; i < children_.size(); i++) { if (children_[i]->isShown()) { -- cgit v0.10.2-6-g49f6