mirror of
https://github.com/atom/atom.git
synced 2026-01-24 22:38:20 -05:00
🐎 Memoize TokenizedLine.prototype.isComment
This commit is contained in:
@@ -491,15 +491,20 @@ class TokenizedLine
|
||||
@endOfLineInvisibles.push(eol) if eol
|
||||
|
||||
isComment: ->
|
||||
return @isCommentLine if @isCommentLine?
|
||||
|
||||
@isCommentLine = false
|
||||
iterator = @getTokenIterator()
|
||||
while iterator.next()
|
||||
scopes = iterator.getScopes()
|
||||
continue if scopes.length is 1
|
||||
continue unless NonWhitespaceRegex.test(iterator.getText())
|
||||
for scope in scopes
|
||||
return true if CommentScopeRegex.test(scope)
|
||||
if CommentScopeRegex.test(scope)
|
||||
@isCommentLine = true
|
||||
break
|
||||
break
|
||||
false
|
||||
@isCommentLine
|
||||
|
||||
isOnlyWhitespace: ->
|
||||
@lineIsWhitespaceOnly
|
||||
|
||||
Reference in New Issue
Block a user