Branch: refs/heads/main
  Home:   https://github.com/WebKit/WebKit
  Commit: 78a45ba1d6081c4040d09569c134c3490f9f0e16
      
https://github.com/WebKit/WebKit/commit/78a45ba1d6081c4040d09569c134c3490f9f0e16
  Author: Chris Dumez <[email protected]>
  Date:   2023-09-06 (Wed, 06 Sep 2023)

  Changed paths:
    M Source/WebCore/page/scrolling/ScrollingStateNode.cpp
    M Source/WebCore/page/scrolling/ScrollingStateNode.h
    M Source/WebCore/page/scrolling/ScrollingStateTree.cpp

  Log Message:
  -----------
  Avoid linear search in ScrollingStateTree::insertNode() when node is already 
present at desired index
https://bugs.webkit.org/show_bug.cgi?id=261209

Reviewed by Simon Fraser.

Avoid linear search in ScrollingStateTree::insertNode() when node is already
present at desired index.

We used to do a linear search to find the index of `child` and then compare it
with `childIndex`. Instead, we now lookup the node at `childIndex` (which is
cheap) and compare it to `child`. This allows us to drop some now unused code
as well.

* Source/WebCore/page/scrolling/ScrollingStateNode.cpp:
(WebCore::ScrollingStateNode::removeChild):
(WebCore::ScrollingStateNode::childAtIndex const):
(WebCore::ScrollingStateNode::removeChildAtIndex): Deleted.
(WebCore::ScrollingStateNode::indexOfChild const): Deleted.
* Source/WebCore/page/scrolling/ScrollingStateNode.h:
* Source/WebCore/page/scrolling/ScrollingStateTree.cpp:
(WebCore::ScrollingStateTree::insertNode):

Canonical link: https://commits.webkit.org/267698@main


_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to