Cache filter results so we don't run all OP filters twice.

This commit is contained in:
ccd0 2016-10-01 18:09:48 -07:00
parent 8c6424f512
commit 4c6701f2f7
2 changed files with 6 additions and 2 deletions

View File

@ -1,5 +1,6 @@
Filter =
filters: {}
results: {}
init: ->
return unless g.VIEW in ['index', 'thread'] and Conf['Filter']
@ -107,6 +108,7 @@ Filter =
settings
test: (post, hideable=true) ->
return post.filterResults if post.filterResults
hl = undefined
top = false
for key of Filter.filters when ((value = Filter[key] post)?)

View File

@ -595,7 +595,7 @@ Index =
for data in Index.liveThreadData
Index.liveThreadDict[data.no] = data
Index.parsedThreads[data.no] = obj = Build.parseJSON data, g.BOARD.ID
results = Filter.test obj
obj.filterResults = results = Filter.test obj
obj.isOnTop = results.top
obj.isHidden = results.hide
if Index.liveThreadData[0]
@ -624,7 +624,9 @@ Index =
threads.push thread
if not ((OP = thread.OP) and not OP.isFetchedQuote)
OP = new Post Build.postFromObject(threadData, g.BOARD.ID, true), thread, g.BOARD
obj = Index.parsedThreads[threadData.no]
OP = new Post Build.post(obj, true), thread, g.BOARD
OP.filterResults = obj.filterResults
posts.push OP
thread.setPage i // Index.threadsNumPerPage + 1