From 2814818e9b7990aff8bd28f22e0375ae8a700c3b Mon Sep 17 00:00:00 2001 From: Zixaphir Date: Mon, 3 Mar 2014 02:27:31 -0700 Subject: [PATCH] Let's just wrap this all up into some nice, nested loops --- builds/4chan-X.user.js | 14 +++++++++----- builds/crx/script.js | 14 +++++++++----- src/General/Index.coffee | 15 ++++++++++----- 3 files changed, 28 insertions(+), 15 deletions(-) diff --git a/builds/4chan-X.user.js b/builds/4chan-X.user.js index 5bfb4b8ab..c6eadb0a9 100644 --- a/builds/4chan-X.user.js +++ b/builds/4chan-X.user.js @@ -3238,17 +3238,21 @@ return Index.buildIndex(); }, parseThreadList: function(pages) { - var i, live, page; + var data, i, j, live, page, thread, threads; Index.threadsNumPerPage = pages[0].threads.length; live = []; + data = []; i = 0; while (page = pages[i++]) { - live = live.concat(page.threads); + j = 0; + threads = page.threads; + live = live.concat(threads); + while (thread = threads[j++]) { + data.push(thread.no); + } } Index.liveThreadData = live; - Index.liveThreadIDs = Index.liveThreadData.map(function(data) { - return data.no; - }); + Index.liveThreadIDs = data; return g.BOARD.threads.forEach(function(thread) { var _ref; if (_ref = thread.ID, __indexOf.call(Index.liveThreadIDs, _ref) < 0) { diff --git a/builds/crx/script.js b/builds/crx/script.js index 9cb6931ac..b2c29f162 100644 --- a/builds/crx/script.js +++ b/builds/crx/script.js @@ -3297,17 +3297,21 @@ return Index.buildIndex(); }, parseThreadList: function(pages) { - var i, live, page; + var data, i, j, live, page, thread, threads; Index.threadsNumPerPage = pages[0].threads.length; live = []; + data = []; i = 0; while (page = pages[i++]) { - live = live.concat(page.threads); + j = 0; + threads = page.threads; + live = live.concat(threads); + while (thread = threads[j++]) { + data.push(thread.no); + } } Index.liveThreadData = live; - Index.liveThreadIDs = Index.liveThreadData.map(function(data) { - return data.no; - }); + Index.liveThreadIDs = data; return g.BOARD.threads.forEach(function(thread) { var _ref; if (_ref = thread.ID, __indexOf.call(Index.liveThreadIDs, _ref) < 0) { diff --git a/src/General/Index.coffee b/src/General/Index.coffee index a03ec67b4..bc1181124 100644 --- a/src/General/Index.coffee +++ b/src/General/Index.coffee @@ -561,14 +561,19 @@ Index = parseThreadList: (pages) -> Index.threadsNumPerPage = pages[0].threads.length - live = [] - i = 0 + data = [] + i = 0 while page = pages[i++] - live = live.concat page.threads + j = 0 + {threads} = page + live = live.concat threads + while thread = threads[j++] + data.push thread.no + + Index.liveThreadData = live + Index.liveThreadIDs = data - Index.liveThreadData = live - Index.liveThreadIDs = Index.liveThreadData.map (data) -> data.no g.BOARD.threads.forEach (thread) -> thread.collect() unless thread.ID in Index.liveThreadIDs