Faster Post::parseQuotes
What changed is about 3~4 times faster now. Resulting code is also less complex.
This commit is contained in:
parent
d583c74049
commit
b628cd7eba
@ -78,25 +78,26 @@ class Post
|
|||||||
parseQuotes: ->
|
parseQuotes: ->
|
||||||
quotes = {}
|
quotes = {}
|
||||||
for quotelink in $$ '.quotelink', @nodes.comment
|
for quotelink in $$ '.quotelink', @nodes.comment
|
||||||
# Don't add board links. (>>>/b/)
|
# Only add quotes that link to posts on an imageboard.
|
||||||
{hash} = quotelink
|
# Don't add:
|
||||||
continue unless hash
|
# - board links. (>>>/b/)
|
||||||
|
# - catalog links. (>>>/b/catalog or >>>/b/search)
|
||||||
# Don't add catalog links. (>>>/b/catalog or >>>/b/search)
|
# - rules links. (>>>/a/rules)
|
||||||
{pathname} = quotelink
|
# - text-board quotelinks. (>>>/img/1234)
|
||||||
continue if /catalog$/.test pathname
|
continue unless match = quotelink.href.match ///
|
||||||
|
boards\.4chan\.org/
|
||||||
# Don't add rules links. (>>>/a/rules)
|
([^/]+) # boardID
|
||||||
# Don't add text-board quotelinks. (>>>/img/1234)
|
/res/\d+#p
|
||||||
continue if quotelink.hostname isnt 'boards.4chan.org'
|
(\d+) # postID
|
||||||
|
$
|
||||||
|
///
|
||||||
|
|
||||||
@nodes.quotelinks.push quotelink
|
@nodes.quotelinks.push quotelink
|
||||||
|
|
||||||
# Don't count capcode replies as quotes in OPs. (Admin/Mod/Dev Replies: ...)
|
# Don't count capcode replies as quotes in OPs. (Admin/Mod/Dev Replies: ...)
|
||||||
continue if !@isReply and $.hasClass quotelink.parentNode.parentNode, 'capcodeReplies'
|
continue if !@isReply and $.hasClass quotelink.parentNode.parentNode, 'capcodeReplies'
|
||||||
|
|
||||||
# Basically, only add quotes that link to posts on an imageboard.
|
quotes["#{match[1]}.#{match[2]}"] = true
|
||||||
quotes["#{pathname.split('/')[1]}.#{hash[2..]}"] = true
|
|
||||||
return if @isClone
|
return if @isClone
|
||||||
@quotes = Object.keys quotes
|
@quotes = Object.keys quotes
|
||||||
|
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user