From 54ee8ff4d4b1458880554bf3a28c92b8c069cb53 Mon Sep 17 00:00:00 2001 From: Maximilian Hils Date: Mon, 6 Jun 2016 15:47:31 -0700 Subject: [PATCH] web: accept all falsey sortFns in sortedIndexOf --- web/src/js/ducks/utils/view.js | 12 ++++-------- 1 file changed, 4 insertions(+), 8 deletions(-) diff --git a/web/src/js/ducks/utils/view.js b/web/src/js/ducks/utils/view.js index ff6f4c129..fa23efcd2 100644 --- a/web/src/js/ducks/utils/view.js +++ b/web/src/js/ducks/utils/view.js @@ -43,12 +43,8 @@ const sortedRemove = (list, sortFn, item) => { } export function sortedIndexOf(list, value, sortFn) { - if (sortFn === false){ - let i = 0 - while (i < list.length && list[i].id !== value.id){ - i++ - } - return i + if (!sortFn) { + sortFn = x => 0 // This triggers the linear search for flows that have the same sort value. } let low = 0, @@ -57,7 +53,7 @@ export function sortedIndexOf(list, value, sortFn) { mid; while (low < high) { mid = (low + high) >>> 1; - if ((sortFn(list[mid]) < val) ) { + if (sortFn(list[mid]) < val) { low = mid + 1 } else { high = mid @@ -125,4 +121,4 @@ export function updateViewFilter(list, filterFn = defaultFilterFn, sortFn = defa filtered.indexOf = x => sortedIndexOf(filtered, x, sortFn) return filtered -} \ No newline at end of file +}