Tal Nisan has uploaded a new change for review. Change subject: frontend: Remove IteratorUtils class ......................................................................
frontend: Remove IteratorUtils class Since we changed the items held in the ListModel from Iterable to Collection, we can now remove IteratorUtils as it's redundant, instead of iterating on the Iterable we can just use the size() method that Collection object has Change-Id: Iace61d708d6e66da4b898a6d6069136e1c838c4f Signed-off-by: Tal Nisan <[email protected]> --- M frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/SearchableListModel.java D frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/IteratorUtils.java 2 files changed, 2 insertions(+), 42 deletions(-) git pull ssh://gerrit.ovirt.org:29418/ovirt-engine refs/changes/23/24523/1 diff --git a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/SearchableListModel.java b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/SearchableListModel.java index 5311ee1..5a2c090 100644 --- a/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/SearchableListModel.java +++ b/frontend/webadmin/modules/uicommonweb/src/main/java/org/ovirt/engine/ui/uicommonweb/models/SearchableListModel.java @@ -38,7 +38,6 @@ import org.ovirt.engine.ui.uicommonweb.models.reports.ReportModel; import org.ovirt.engine.ui.uicompat.Event; import org.ovirt.engine.ui.uicompat.EventArgs; -import org.ovirt.engine.ui.uicompat.IteratorUtils; import org.ovirt.engine.ui.uicompat.NotifyCollectionChangedEventArgs; import org.ovirt.engine.ui.uicompat.PropertyChangedEventArgs; @@ -672,28 +671,18 @@ protected boolean getNextSearchPageAllowed() { if (!getSearchNextPageCommand().getIsAvailable() || getItems() == null - || IteratorUtils.moveNext(getItems().iterator()) == false) + || getItems().iterator().hasNext()) { return false; } boolean retValue = true; - // ** TODO: Inefficient performance-wise! If 'Items' was ICollection or IList - // ** it would be better, since we could simply check its 'Count' property. - int pageSize = getSearchPageSize(); if (pageSize > 0) { - Iterator e = getItems().iterator(); - int itemsCountInCurrentPage = 0; - while (IteratorUtils.moveNext(e)) - { - itemsCountInCurrentPage++; - } - - if (itemsCountInCurrentPage < pageSize) + if (getItems().size() < pageSize) { // current page contains results quantity smaller than // the pageSize -> there is no next page: diff --git a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/IteratorUtils.java b/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/IteratorUtils.java deleted file mode 100644 index d113806..0000000 --- a/frontend/webadmin/modules/uicompat/src/main/java/org/ovirt/engine/ui/uicompat/IteratorUtils.java +++ /dev/null @@ -1,29 +0,0 @@ -package org.ovirt.engine.ui.uicompat; - -import java.util.Iterator; - -public class IteratorUtils { - - /// <summary> - - /// Advances to the next item in the specified enumerator and returns true. - - /// If no item has left to advance to - return false - - /// </summary> - - /// <param name="enumerator">specified enumerator</param> - - /// <returns>true if advanced to next item, false otherwise</returns> - - @SuppressWarnings("rawtypes") - public static boolean moveNext(Iterator iterator) { - if (iterator.hasNext()) { - iterator.next(); - return true; - } - else { - return false; - } - } -} -- To view, visit http://gerrit.ovirt.org/24523 To unsubscribe, visit http://gerrit.ovirt.org/settings Gerrit-MessageType: newchange Gerrit-Change-Id: Iace61d708d6e66da4b898a6d6069136e1c838c4f Gerrit-PatchSet: 1 Gerrit-Project: ovirt-engine Gerrit-Branch: master Gerrit-Owner: Tal Nisan <[email protected]> _______________________________________________ Engine-patches mailing list [email protected] http://lists.ovirt.org/mailman/listinfo/engine-patches
