Skip to content
This repository was archived by the owner on Dec 15, 2022. It is now read-only.

Commit 03d835b

Browse files
committed
Cache hasAstral calls, invalidating any time the text changes
1 parent 4453fc9 commit 03d835b

File tree

1 file changed

+8
-1
lines changed

1 file changed

+8
-1
lines changed

src/text-buffer.coffee

Lines changed: 8 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,6 +170,7 @@ class TextBuffer
170170
@nextMarkerId = 1
171171
@outstandingSaveCount = 0
172172
@loadCount = 0
173+
@cachedHasAstral = null
173174
@_emittedWillChangeEvent = false
174175

175176
@setEncoding(params?.encoding)
@@ -732,7 +733,12 @@ class TextBuffer
732733
# are encoded as surrogate pairs.
733734
#
734735
# Returns a {Boolean}.
735-
hasAstral: -> @buffer.hasAstral()
736+
hasAstral: ->
737+
if @cachedHasAstral isnt null
738+
@cachedHasAstral
739+
else
740+
@cachedHasAstral = @buffer.hasAstral()
741+
@cachedHasAstral
736742

737743
###
738744
Section: Mutating Text
@@ -2072,6 +2078,7 @@ class TextBuffer
20722078
@_emittedWillChangeEvent = true
20732079

20742080
emitDidChangeTextEvent: ->
2081+
@cachedHasAstral = null
20752082
if @transactCallDepth is 0
20762083
if @changesSinceLastDidChangeTextEvent.length > 0
20772084
compactedChanges = patchFromChanges(@changesSinceLastDidChangeTextEvent).getChanges()

0 commit comments

Comments
 (0)