efficiency improvement to ComparePointToRange()

git-svn-id: svn://10.0.0.236/trunk@18276 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
jfrancis%netscape.com
1999-01-22 08:59:26 +00:00
parent ca8e5f4cdd
commit 8f3f641ccb
2 changed files with 26 additions and 2 deletions

View File

@@ -393,7 +393,7 @@ nsresult nsRange::ComparePointToRange(nsIDOMNode* aParent, PRInt32 aOffset, PRIn
// no trivial cases please
if (!aParent) return NS_ERROR_NULL_POINTER;
// our rnage is in a good state?
// our range is in a good state?
if (!mIsPositioned) return NS_ERROR_NOT_INITIALIZED;
// check common case first
@@ -413,6 +413,18 @@ nsresult nsRange::ComparePointToRange(nsIDOMNode* aParent, PRInt32 aOffset, PRIn
return NS_OK;
}
// more common cases
if ((aParent == mStartParent) && (aOffset == mStartOffset))
{
*aResult = 0;
return NS_OK;
}
if ((aParent == mEndParent) && (aOffset == mEndOffset))
{
*aResult = 0;
return NS_OK;
}
// ok, do it the hard way
if (IsIncreasing(aParent,aOffset,mStartParent,mStartOffset)) *aResult = -1;
else if (IsIncreasing(mEndParent,mEndOffset,aParent,aOffset)) *aResult = 1;