mirror of
https://github.com/atom/atom.git
synced 2026-01-23 22:08:08 -05:00
Disable periodic serialization for buffers > 2MB
Writing so much data to IndexedDB is blocking the main thread for perceptible amounts of time. A patch-based representation of the modified state could allows us to pay only for what has changed, but is too complex to justify implementing right now to support full crash recovery for large files. Signed-off-by: Max Brunsfeld <maxbrunsfeld@github.com>
This commit is contained in:
committed by
Max Brunsfeld
parent
fb7e25ece6
commit
dea7cc23e3
@@ -70,7 +70,15 @@ class Project extends Model
|
||||
serialize: (options={}) ->
|
||||
deserializer: 'Project'
|
||||
paths: @getPaths()
|
||||
buffers: _.compact(@buffers.map (buffer) -> buffer.serialize({markerLayers: options.isUnloading is true}) if buffer.isRetained())
|
||||
buffers: _.compact(@buffers.map (buffer) ->
|
||||
if buffer.isRetained()
|
||||
state = buffer.serialize({markerLayers: options.isUnloading is true})
|
||||
# Skip saving large buffer text unless unloading to avoid blocking main thread
|
||||
if not options.isUnloading and state.text.length > 2 * 1024 * 1024
|
||||
delete state.text
|
||||
delete state.digestWhenLastPersisted
|
||||
state
|
||||
)
|
||||
|
||||
###
|
||||
Section: Event Subscription
|
||||
|
||||
Reference in New Issue
Block a user