Closed Bug 262764 Opened 20 years ago Closed 20 years ago

[FIXr]ComparePoints() is pretty slow

Categories

(Core :: DOM: Core & HTML, defect, P2)

x86
Linux
defect

Tracking

()

RESOLVED FIXED
mozilla1.8alpha5

People

(Reporter: bzbarsky, Assigned: bzbarsky)

Details

(Keywords: perf)

Attachments

(1 file, 1 obsolete file)

ComparePoints creates a new range, does a bunch of random manipulation, etc.  It
doesn't need to do any of that stuff, really.

Timing setting of innerHTML, 10% of it is spent in ComparePoints().  I'll attach
a patch that reduces that to 1%.
Attached patch Patch (obsolete) — Splinter Review
Comment on attachment 160978 [details] [diff] [review]
Patch

The changes to GetNodeBracketPoints were just removing unnecessary QIs and
such.

In addition, would it make sense to make IsIncreasing just use
CompareTreePosition?  The locking is pretty expensive; I have to wonder whether
the stack-allocation of arrays that CompareTreePosition does is faster...
Attachment #160978 - Flags: superreview?(peterv)
Attachment #160978 - Flags: review?(peterv)
Priority: -- → P2
Summary: ComparePoints() is pretty slow → [FIX]ComparePoints() is pretty slow
Target Milestone: --- → mozilla1.8alpha5
Comment on attachment 160978 [details] [diff] [review]
Patch

This is wrong.	There are more callers than that.
Attachment #160978 - Flags: superreview?(peterv)
Attachment #160978 - Flags: superreview-
Attachment #160978 - Flags: review?(peterv)
Attachment #160978 - Flags: review-
Attachment #160978 - Attachment is obsolete: true
Attachment #161020 - Flags: superreview?(peterv)
Attachment #161020 - Flags: review?(peterv)
Comment on attachment 161020 [details] [diff] [review]
Fixed so it all works

>Index: content/base/src/nsRange.cpp
>===================================================================

>-  if (!(*outParent)) // special case for root node
>+  if (!parent) // special case for root node
>   {
>     // can't make a parent/offset pair to represent start or 
>     // end of the root node, becasue it has no parent.
>     // so instead represent it by (node,0) and (node,numChildren)
>     *outParent = do_QueryInterface(aNode);
>-    nsCOMPtr<nsIContent> cN(do_QueryInterface(*outParent));
>-    if (!cN)
>-      return PR_FALSE;

It'd be funny if it wasn't sad.

> NS_IMETHODIMP_(PRBool) 
> nsRangeUtils::IsNodeIntersectsRange(nsIContent* aNode, nsIDOMRange* aRange)
> {
>-  return ::IsNodeIntersectsRange( aNode,  aRange);
>+  return nsRange::IsNodeIntersectsRange( aNode,  aRange);
> }

Do we even need this? Seem unused.

>Index: content/base/src/nsSelection.cpp
>===================================================================

>@@ -5037,22 +5039,22 @@ nsTypedSelection::LookUpSelection(nsICon
>           newDetails->mEnd = PR_MIN(aContentLength, endOffset - aContentOffset);
>           newDetails->mType = aType;
>         }
>       }
>       else { //then we MUST be completely selected! unless someone needs us to check to make sure with slowcheck
> 
>         if (cnt > 1 || aSlowCheck){ //if more than 1 selection or we need to do slow check see if farther than start or less than end.
>           //we only have to look at start offset because anything else would have been in the range
>-          PRInt32 resultnum = ComparePoints(startNode, startOffset 
>-                                  ,passedInNode, aContentOffset);
>+          PRInt32 resultnum = nsRange::ComparePoints(startNode, startOffset,
>+                                                     passedInNode, aContentOffset);

Long line.
Attachment #161020 - Flags: superreview?(peterv)
Attachment #161020 - Flags: superreview+
Attachment #161020 - Flags: review?(peterv)
Attachment #161020 - Flags: review+
> Do we even need this? Seem unused.

I'm not sure, but it doesn't cost us much to expose it, so.... ;)

> Long line.

Will fix.
Summary: [FIX]ComparePoints() is pretty slow → [FIXr]ComparePoints() is pretty slow
Fixed on trunk.
Status: NEW → RESOLVED
Closed: 20 years ago
Resolution: --- → FIXED
Keywords: perf
Component: DOM: Traversal-Range → DOM: Core & HTML
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: