switch to faster string search API

This commit is contained in:
rickg%netscape.com 1999-07-19 03:29:56 +00:00
parent 102e131abf
commit 23b232d248
23 changed files with 38 additions and 38 deletions

View File

@ -2428,8 +2428,8 @@ XULDocumentImpl::SplitProperty(nsIRDFResource* aProperty,
// First try to split the namespace using the rightmost '#' or '/'
// character.
if ((i = uri.RFind('#')) < 0) {
if ((i = uri.RFind('/')) < 0) {
if ((i = uri.RFindChar('#')) < 0) {
if ((i = uri.RFindChar('/')) < 0) {
*aNameSpaceID = kNameSpaceID_None;
*aTag = NS_NewAtom(uri);
return NS_OK;

View File

@ -229,7 +229,7 @@ nsStringBundle::GetInputStream(const char* aURLSpec, nsILocale* aLocale, nsIInpu
/* assume the name always ends with this
*/
PRInt32 dot = strFile.RFindCharInSet(".");
PRInt32 dot = strFile.RFindChar('.');
count = strFile.Left(fileLeft, (dot>0)?dot:mylen);
strFile2 += fileLeft;

View File

@ -5296,13 +5296,13 @@ nsCSSFrameConstructor::ConstructAlternateImageFrame(nsIPresContext* aPresContex
imageElement->GetSrc(altText);
if (altText.Length() > 0) {
// Trim off the path part of the filename
PRInt32 offset = altText.RFind('/');
PRInt32 offset = altText.RFindChar('/');
if (offset >= 0) {
altText.Cut(0, offset + 1);
}
// Trim off the extension
offset = altText.RFind('.');
offset = altText.RFindChar('.');
if (offset >= 0) {
altText.Truncate(offset);
}

View File

@ -322,7 +322,7 @@ void nsObjectFrame::IsSupportedImage(nsIContent* aContent, PRBool* aImage)
nsAutoString ext;
PRInt32 iLastCharOffset = data.Length() - 1;
PRInt32 iPointOffset = data.RFind(".");
PRInt32 iPointOffset = data.RFindChar('.');
if(iPointOffset != -1)
{

View File

@ -322,7 +322,7 @@ void nsObjectFrame::IsSupportedImage(nsIContent* aContent, PRBool* aImage)
nsAutoString ext;
PRInt32 iLastCharOffset = data.Length() - 1;
PRInt32 iPointOffset = data.RFind(".");
PRInt32 iPointOffset = data.RFindChar('.');
if(iPointOffset != -1)
{

View File

@ -5296,13 +5296,13 @@ nsCSSFrameConstructor::ConstructAlternateImageFrame(nsIPresContext* aPresContex
imageElement->GetSrc(altText);
if (altText.Length() > 0) {
// Trim off the path part of the filename
PRInt32 offset = altText.RFind('/');
PRInt32 offset = altText.RFindChar('/');
if (offset >= 0) {
altText.Cut(0, offset + 1);
}
// Trim off the extension
offset = altText.RFind('.');
offset = altText.RFindChar('.');
if (offset >= 0) {
altText.Truncate(offset);
}

View File

@ -1085,7 +1085,7 @@ NS_IMETHODIMP nsImapMailFolder::PossibleImapMailbox(
uri.Append(aSpec->hostName);
#if 0
PRInt32 leafPos = folderName.RFind("/", PR_TRUE);
PRInt32 leafPos = folderName.RFindChar('/');
if (leafPos > 0)
{
uri.Append('/');

View File

@ -177,7 +177,7 @@ nsImapURI2Name(const char* rootURI, const char* uriStr, nsString& name)
nsAutoString uri = uriStr;
if (uri.Find(rootURI) != 0) // if doesn't start with rootURI
return NS_ERROR_FAILURE;
PRInt32 pos = uri.RFind("/");
PRInt32 pos = uri.RFindChar('/');
PRInt32 length = uri.Length();
PRInt32 count = length - (pos + 1);
return uri.Right(name, count);

View File

@ -210,14 +210,14 @@ nsLocalURI2Name(const char* rootURI, char* uriStr, nsString& name)
nsAutoString uri = uriStr;
if (uri.Find(rootURI) != 0) // if doesn't start with rootURI
return NS_ERROR_FAILURE;
PRInt32 pos = uri.RFind('/');
PRInt32 pos = uri.RFindChar('/');
PRInt32 length = uri.Length();
// if the last character is a /, chop it off and search again
if (pos == (length-1)) {
uri.Truncate(length-1); // chop the last character
length--;
pos = uri.RFind('/');
pos = uri.RFindChar('/');
}
PRInt32 count = length - (pos + 1);

View File

@ -215,7 +215,7 @@ nsNewsURI2Name(const char* rootURI, const char* uriStr, nsString& name)
nsAutoString uri = uriStr;
if (uri.Find(rootURI) != 0) // if doesn't start with rootURI
return NS_ERROR_FAILURE;
PRInt32 pos = uri.RFind("/");
PRInt32 pos = uri.RFindChar('/');
PRInt32 length = uri.Length();
PRInt32 count = length - (pos + 1);
return uri.Right(name, count);

View File

@ -499,7 +499,7 @@ nsFileChannel::GetContentType(char * *aContentType)
// find the file extension
nsString2 specStr(cStrSpec);
nsString2 extStr;
PRInt32 extLoc = specStr.RFind('.');
PRInt32 extLoc = specStr.RFindChar('.');
if (-1 != extLoc) {
specStr.Right(extStr, specStr.Length() - extLoc - 1);
char *ext = extStr.ToNewCString();

View File

@ -239,7 +239,7 @@ nsHTTPChannel::GetContentType(char * *aContentType)
// find the file extension
nsString2 specStr(cStrSpec);
nsString2 extStr;
PRInt32 extLoc = specStr.RFind('.');
PRInt32 extLoc = specStr.RFindChar('.');
if (-1 != extLoc) {
specStr.Right(extStr, specStr.Length() - extLoc - 1);
char *ext = extStr.ToNewCString();

View File

@ -1080,9 +1080,9 @@ RDFXMLDataSourceImpl::MakeQName(nsIRDFResource* resource,
}
// Okay, so we don't have it in our map. Try to make one up.
PRInt32 i = uri.RFind('#'); // first try a '#'
PRInt32 i = uri.RFindChar('#'); // first try a '#'
if (i == -1) {
i = uri.RFind('/');
i = uri.RFindChar('/');
if (i == -1) {
// Okay, just punt and assume there is _no_ namespace on
// this thing...

View File

@ -393,11 +393,11 @@ nsBrowsingProfile::CountPageVisit(const char* initialURL)
nsAutoString urlStr(initialURL);
// first chop off any query part of the initialURL
pos = urlStr.RFind("?");
pos = urlStr.RFindChar('?');
if (pos >= 0) {
urlStr.Cut(pos, urlStr.Length());
}
pos = urlStr.RFind("#");
pos = urlStr.RFindChar('#');
if (pos >= 0) {
urlStr.Cut(pos, urlStr.Length());
}
@ -460,7 +460,7 @@ nsBrowsingProfile::CountPageVisit(const char* initialURL)
}
// _Now_ find the right most forward-slash
pos = urlStr.RFind("/");
pos = urlStr.RFindChar('/');
if (pos >= 0) {
// leave the last '/', as this is the way most opendir

View File

@ -2428,8 +2428,8 @@ XULDocumentImpl::SplitProperty(nsIRDFResource* aProperty,
// First try to split the namespace using the rightmost '#' or '/'
// character.
if ((i = uri.RFind('#')) < 0) {
if ((i = uri.RFind('/')) < 0) {
if ((i = uri.RFindChar('#')) < 0) {
if ((i = uri.RFindChar('/')) < 0) {
*aNameSpaceID = kNameSpaceID_None;
*aTag = NS_NewAtom(uri);
return NS_OK;

View File

@ -437,7 +437,7 @@ FTPDataSource::GetName(nsIRDFResource *source, nsIRDFLiteral** aResult)
}
// get basename
PRInt32 slash = url.RFind('/');
PRInt32 slash = url.RFindChar('/');
if (slash > 0)
{
url.Cut(0, slash+1);

View File

@ -1106,9 +1106,9 @@ SearchDataSource::GetSearchEngineList()
#endif
{
#ifdef XP_MAC
PRInt32 separatorOffset = uri.RFind(":");
PRInt32 separatorOffset = uri.RFindChar(':');
#else
PRInt32 separatorOffset = uri.RFind("/");
PRInt32 separatorOffset = uri.RFindChar('/');
#endif
if (separatorOffset > 0)
{
@ -1241,7 +1241,7 @@ SearchDataSource::ReadFileContents(char *baseFilename, nsString& sourceContents)
PRBool wasAliased = PR_FALSE;
fileSpec.ResolveAlias(wasAliased);
nsAutoString childPath(childURL);
PRInt32 separatorOffset = childPath.RFind(":");
PRInt32 separatorOffset = childPath.RFindChar(':');
if (separatorOffset > 0)
{
childPath.Cut(0, separatorOffset+1);

View File

@ -148,7 +148,7 @@ CreateOutFileLocation(const nsString& url, const nsString& directory)
{
nsSpecialSystemDirectory outFileLocation(nsSpecialSystemDirectory::OS_CurrentProcessDirectory);
PRInt32 result = url.RFind('/');
PRInt32 result = url.RFindChar('/');
if (result != -1)
{
nsString fileName;

View File

@ -414,7 +414,7 @@ nsWebCrawler::GetOutputFile(nsIURI *aURL, nsString& aOutputName)
#ifdef NECKO
nsCRT::free(file);
#endif
PRInt32 fileNameOffset = inputFileFullPath.RFind('/');
PRInt32 fileNameOffset = inputFileFullPath.RFindChar('/');
if (-1==fileNameOffset)
{
inputFileName = new char[strlen(kDefaultOutputFileName) + 1];

View File

@ -71,11 +71,11 @@
#endif
#ifdef XP_PC
#define FILESEP "\\"
#define FILESEP '\\'
#elif defined(XP_MAC)
#define FILESEP ":"
#define FILESEP ':'
#else
#define FILESEP "/"
#define FILESEP '/'
#endif
static NS_DEFINE_IID(kEventQueueServiceCID, NS_EVENTQUEUESERVICE_CID);
@ -791,7 +791,7 @@ nsInstall::GetComponentFolder(const nsString& aComponentName, const nsString& aS
int i;
nsString dirStr(dir);
if ( (i = dirStr.RFind(FILESEP)) > 0 )
if ( (i = dirStr.RFindChar(FILESEP)) > 0 )
{
// i is the index in the string, not the total number of
// characters in the string. ToCString() requires the
@ -1906,7 +1906,7 @@ nsInstall::ExtractFileFromJar(const nsString& aJarfile, nsFileSpec* aSuggestedNa
nsString tempFileName = "xpinstall";
// Get the extension of the file in the JAR
result = aJarfile.RFind(".");
result = aJarfile.RFindChar('.');
if (result != -1)
{
// We found the extension; add it to the tempFileName string

View File

@ -420,7 +420,7 @@ nsInstallPatch::NativePatch(const nsFileSpec &sourceFile, const nsFileSpec &patc
nsString newFileName = sourceFile.GetLeafName();
PRInt32 index;
if ((index = newFileName.RFind(".")) > 0)
if ((index = newFileName.RFindChar('.')) > 0)
{
nsString extention;
nsString fileName;

View File

@ -285,14 +285,14 @@ nsInstallTrigger::CreateTempFileFromURL(const nsString& aURL, nsString& tempFile
{
nsSpecialSystemDirectory tempFile(nsSpecialSystemDirectory::OS_TemporaryDirectory);
PRInt32 result = aURL.RFind("/");
PRInt32 result = aURL.RFindChar('/');
if (result != -1)
{
nsString jarName;
aURL.Right(jarName, (aURL.Length() - result) );
PRInt32 argOffset = jarName.RFind("?");
PRInt32 argOffset = jarName.RFindChar('?');
if (argOffset != -1)
{

View File

@ -187,7 +187,7 @@ nsresult nsXPInstallManager::DownloadNext()
// --- figure out a temp file name
nsSpecialSystemDirectory temp(nsSpecialSystemDirectory::OS_TemporaryDirectory);
PRInt32 pos = mItem->mURL.RFind('/');
PRInt32 pos = mItem->mURL.RFindChar('/');
if ( pos != -1 )
{
nsString jarleaf;