From 53258c59aed6ec904fe7ce58412c553b05bff18a Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Mon, 3 Mar 2014 02:18:37 -0700 Subject: [PATCH] Reduce reduce. --- builds/4chan-X.user.js | 10 +++++++--- builds/crx/script.js | 10 +++++++--- src/General/Index.coffee | 10 ++++++++-- 3 files changed, 22 insertions(+), 8 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 00c6d3cac..5bfb4b8ab 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -3238,10 +3238,14 @@ return Index.buildIndex(); }, parseThreadList: function(pages) { + var i, live, page; Index.threadsNumPerPage = pages[0].threads.length; - Index.liveThreadData = pages.reduce((function(arr, next) { - return arr.concat(next.threads); - }), []); + live = []; + i = 0; + while (page = pages[i++]) { + live = live.concat(page.threads); + } + Index.liveThreadData = live; Index.liveThreadIDs = Index.liveThreadData.map(function(data) { return data.no; }); diff --git a/builds/crx/script.js b/builds/crx/script.js index 7d44b7b83..9cb6931ac 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -3297,10 +3297,14 @@ return Index.buildIndex(); }, parseThreadList: function(pages) { + var i, live, page; Index.threadsNumPerPage = pages[0].threads.length; - Index.liveThreadData = pages.reduce((function(arr, next) { - return arr.concat(next.threads); - }), []); + live = []; + i = 0; + while (page = pages[i++]) { + live = live.concat(page.threads); + } + Index.liveThreadData = live; Index.liveThreadIDs = Index.liveThreadData.map(function(data) { return data.no; }); diff --git a/src/General/Index.coffee b/src/General/Index.coffee index 76cf3f469..a03ec67b4 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -561,8 +561,14 @@ Index = parseThreadList: (pages) -> Index.threadsNumPerPage = pages[0].threads.length - Index.liveThreadData = pages.reduce ((arr, next) -> arr.concat next.threads), [] - Index.liveThreadIDs = Index.liveThreadData.map (data) -> data.no + + live = [] + i = 0 + while page = pages[i++] + live = live.concat page.threads + + Index.liveThreadData = live + Index.liveThreadIDs = Index.liveThreadData.map (data) -> data.no g.BOARD.threads.forEach (thread) -> thread.collect() unless thread.ID in Index.liveThreadIDs