From 553c4757686e6277b9fc4166a04b5746bfd6327e Mon Sep 17 00:00:00 2001 From: Mayhem Date: Thu, 31 Oct 2013 03:42:24 +0100 Subject: [PATCH] Reduce Index.sort() to 1 loop. --- src/Miscellaneous/Index.coffee | 14 +++++++------- 1 file changed, 7 insertions(+), 7 deletions(-) diff --git a/src/Miscellaneous/Index.coffee b/src/Miscellaneous/Index.coffee index e06236f2c..8de6fa1de 100644 --- a/src/Miscellaneous/Index.coffee +++ b/src/Miscellaneous/Index.coffee @@ -122,14 +122,14 @@ Index = $('.pagelist').hidden = Conf['Index Mode'] isnt 'paged' sort: (nodes) -> return nodes unless Conf['Filter'] - # Put the highlighted thread on top of the index + # Put the highlighted thread &
on top of the index # while keeping the original order they appear in. - tops = [] - for threadRoot in nodes by 2 when Get.threadFromRoot(threadRoot).isOnTop - tops.push threadRoot - for top, i in tops - arr = nodes.splice nodes.indexOf(top), 2 - nodes.splice i * 2, 0, arr... + i = offset = 0 + while threadRoot = nodes[i] + if Get.threadFromRoot(threadRoot).isOnTop + nodes.splice offset, 0, nodes.splice(i, 2)... + offset += 2 + i += 2 nodes collectDeadThreads: (liveThreads) ->