Skip to content

Commit

Permalink
cool#10440 - perf: don't touch comment's innerText unless it changes.
Browse files Browse the repository at this point in the history
Previously CanvasSectionContainer.onMouseWheel - spent 30% of its
time setting comment properties to the same value.

Signed-off-by: Michael Meeks <[email protected]>
Change-Id: I0e50de9bae65db762fd6637618002485514c13b6
  • Loading branch information
mmeeks authored and timar committed Nov 12, 2024
1 parent aeec4b7 commit 9b5b808
Showing 1 changed file with 8 additions and 4 deletions.
12 changes: 8 additions & 4 deletions browser/src/canvas/sections/CommentSection.ts
Original file line number Diff line number Diff line change
Expand Up @@ -1540,14 +1540,18 @@ export class Comment extends CanvasSectionObject {
if (this.sectionProperties.docLayer._docType === 'spreadsheet')
return;

var innerText;
if (this.isEdit())
this.sectionProperties.collapsedInfoNode.innerText = '!';
innerText = '!';
else if (replycount === '!' || typeof replycount === "number" && replycount > 0)
this.sectionProperties.collapsedInfoNode.innerText = replycount;
innerText = replycount;
else
this.sectionProperties.collapsedInfoNode.innerText = '';
innerText = '';

if (this.sectionProperties.collapsedInfoNode.innerText === '' || this.isContainerVisible())
if (this.sectionProperties.collapsedInfoNode.innerText != innerText)
this.sectionProperties.collapsedInfoNode.innerText = innerText;

if (innerText === '' || this.isContainerVisible())
this.sectionProperties.collapsedInfoNode.style.display = 'none';
else if ((!this.isContainerVisible() && this.sectionProperties.collapsedInfoNode.innerText !== ''))
this.sectionProperties.collapsedInfoNode.style.display = '';
Expand Down

0 comments on commit 9b5b808

Please sign in to comment.