Cache filter results so we don't run all OP filters twice.
This commit is contained in:
parent
8c6424f512
commit
4c6701f2f7
@ -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)?)
|
||||
|
||||
@ -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
|
||||
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user