fixed bug in nsString2::find() -- this will soon use boyer-moore

git-svn-id: svn://10.0.0.236/trunk@32925 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
rickg%netscape.com
1999-05-27 07:59:16 +00:00
parent 0ca0dd52fd
commit 50850f828c
3 changed files with 6 additions and 66 deletions

View File

@@ -450,21 +450,11 @@ PRInt32 nsStr::FindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgnor
PRBool matches=PR_TRUE;
while((++theSubIndex<theTargetMax) && (matches)){
PRUnichar theChar=GetCharAt(aDest,index+theSubIndex);
if(theSubIndex>0) {
if(theFirstTargetChar==theChar){
PRUnichar theDestJumpChar=GetCharAt(aDest,index+theTargetMax);
if(theDestJumpChar==theLastTargetChar) {
theNewStartPos=index; //this lets us jump ahead during our search where possible.
}//if
}//if
}//if
PRUnichar theTargetChar=GetCharAt(aTarget,theSubIndex);
matches=PRBool(theChar==theTargetChar);
}
if(matches)
if(matches) {
return index;
if(-1<theNewStartPos){
index=theNewStartPos-1;
}
}
}//if
@@ -524,22 +514,12 @@ PRInt32 nsStr::RFindSubstr(const nsStr& aDest,const nsStr& aTarget, PRBool aIgno
if(anOffset+aTarget.mLength<=aDest.mLength) {
while((++theSubIndex<theTargetMax) && (matches)){
PRUnichar theChar=GetCharAt(aDest,index+theSubIndex);
if(theSubIndex>0) {
if(theFirstTargetChar==theChar){
PRUnichar theDestJumpChar=GetCharAt(aDest,index+theTargetMax);
if(theDestJumpChar==theLastTargetChar) {
theNewStartPos=index; //this lets us jump ahead during our search where possible.
}//if
}//if
}//if
PRUnichar theTargetChar=GetCharAt(aTarget,theSubIndex);
matches=PRBool(theChar==theTargetChar);
} //while
} //if
if(matches)
if(matches) {
return index;
if(-1<theNewStartPos){
index=theNewStartPos-1;
}
}
}//if