small performance enhancement -- less searching

This commit is contained in:
rickg%netscape.com 1999-05-28 07:14:08 +00:00
Родитель 1a121d89d6
Коммит ad482c8baf
4 изменённых файлов: 8 добавлений и 4 удалений

Просмотреть файл

@ -424,7 +424,7 @@ eParseMode DetermineParseMode(nsParser& aParser) {
if(theScanner){ if(theScanner){
nsString theBufCopy; nsString theBufCopy;
nsString& theBuffer=theScanner->GetBuffer(); nsString& theBuffer=theScanner->GetBuffer();
theBuffer.Left(theBufCopy,300); theBuffer.Left(theBufCopy,125);
theBufCopy.ToUpperCase(); theBufCopy.ToUpperCase();
PRInt32 theIndex=theBufCopy.Find("<!DOCTYPE"); PRInt32 theIndex=theBufCopy.Find("<!DOCTYPE");
if(kNotFound==theIndex){ if(kNotFound==theIndex){

Просмотреть файл

@ -184,7 +184,9 @@ eAutoDetectResult CWellFormedDTD::CanParse(nsString& aContentType, nsString& aCo
result=eValidDetect; result=eValidDetect;
} }
else { else {
if(-1<aBuffer.Find("<?xml ")) { nsAutoString temp;
aBuffer.Left(temp,150); //let's only scan the first 150 or so bytes...
if(-1<temp.Find("<?xml ")) {
if(0==aContentType.Length()) { if(0==aContentType.Length()) {
aContentType = kXMLTextContentType; //only reset it if it's empty aContentType = kXMLTextContentType; //only reset it if it's empty
} }

Просмотреть файл

@ -424,7 +424,7 @@ eParseMode DetermineParseMode(nsParser& aParser) {
if(theScanner){ if(theScanner){
nsString theBufCopy; nsString theBufCopy;
nsString& theBuffer=theScanner->GetBuffer(); nsString& theBuffer=theScanner->GetBuffer();
theBuffer.Left(theBufCopy,300); theBuffer.Left(theBufCopy,125);
theBufCopy.ToUpperCase(); theBufCopy.ToUpperCase();
PRInt32 theIndex=theBufCopy.Find("<!DOCTYPE"); PRInt32 theIndex=theBufCopy.Find("<!DOCTYPE");
if(kNotFound==theIndex){ if(kNotFound==theIndex){

Просмотреть файл

@ -184,7 +184,9 @@ eAutoDetectResult CWellFormedDTD::CanParse(nsString& aContentType, nsString& aCo
result=eValidDetect; result=eValidDetect;
} }
else { else {
if(-1<aBuffer.Find("<?xml ")) { nsAutoString temp;
aBuffer.Left(temp,150); //let's only scan the first 150 or so bytes...
if(-1<temp.Find("<?xml ")) {
if(0==aContentType.Length()) { if(0==aContentType.Length()) {
aContentType = kXMLTextContentType; //only reset it if it's empty aContentType = kXMLTextContentType; //only reset it if it's empty
} }