From a2d67c101e1c383e20aff2991d832cff66ca3784 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Tue, 20 Dec 2016 11:22:20 -0500 Subject: [PATCH 1/3] Avoid recording duplicate child views to eliminate extra GC work --- src/trix/views/object_view.coffee | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/trix/views/object_view.coffee b/src/trix/views/object_view.coffee index 43c38ff91..e9e40eb9d 100644 --- a/src/trix/views/object_view.coffee +++ b/src/trix/views/object_view.coffee @@ -36,7 +36,8 @@ class Trix.ObjectView extends Trix.BasicObject recordChildView: (view) -> view.parentView = this view.rootView = @rootView - @childViews.push(view) + unless view in @childViews + @childViews.push(view) view getAllChildViews: -> From 36b859b124c48f7aa5b387d4e04fb58d99c7b4ab Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Tue, 20 Dec 2016 11:23:35 -0500 Subject: [PATCH 2/3] Insert multiple files in a single operation --- src/trix/controllers/input_controller.coffee | 2 +- src/trix/models/composition.coffee | 8 ++++++++ 2 files changed, 9 insertions(+), 1 deletion(-) diff --git a/src/trix/controllers/input_controller.coffee b/src/trix/controllers/input_controller.coffee index 218b7947a..5b39b90f1 100644 --- a/src/trix/controllers/input_controller.coffee +++ b/src/trix/controllers/input_controller.coffee @@ -119,7 +119,7 @@ class Trix.InputController extends Trix.BasicObject Promise.all(operations).then (files) => @handleInput -> @delegate?.inputControllerWillAttachFiles() - @responder?.insertFile(file) for file in files + @responder?.insertFiles(files) @requestRender() # Input handlers diff --git a/src/trix/models/composition.coffee b/src/trix/models/composition.coffee index 59e278a84..eede5dff1 100644 --- a/src/trix/models/composition.coffee +++ b/src/trix/models/composition.coffee @@ -113,6 +113,14 @@ class Trix.Composition extends Trix.BasicObject attachment = Trix.Attachment.attachmentForFile(file) @insertAttachment(attachment) + insertFiles: (files) -> + text = new Trix.Text + for file in files when @delegate?.compositionShouldAcceptFile(file) + attachment = Trix.Attachment.attachmentForFile(file) + attachmentText = Trix.Text.textForAttachmentWithAttributes(attachment, @currentAttributes) + text = text.appendText(attachmentText) + @insertText(text) + insertAttachment: (attachment) -> text = Trix.Text.textForAttachmentWithAttributes(attachment, @currentAttributes) @insertText(text) From 5e5a94fa6f6a0e046bc3c8a0842b279ffc4038d4 Mon Sep 17 00:00:00 2001 From: Javan Makhmali Date: Tue, 20 Dec 2016 17:04:31 -0500 Subject: [PATCH 3/3] Add GC perf to inspector --- src/trix/inspector/views/performance_view.coffee | 1 + 1 file changed, 1 insertion(+) diff --git a/src/trix/inspector/views/performance_view.coffee b/src/trix/inspector/views/performance_view.coffee index 76bd6ad6f..b0a6e66f9 100644 --- a/src/trix/inspector/views/performance_view.coffee +++ b/src/trix/inspector/views/performance_view.coffee @@ -11,6 +11,7 @@ Trix.Inspector.registerView class extends Trix.Inspector.View @data = {} @track("documentView.render") @track("documentView.sync") + @track("documentView.garbageCollectCachedViews") @track("composition.replaceHTML") @render()