From 59133b416a6612e9e1314e68cf55331bb1d77fa9 Mon Sep 17 00:00:00 2001 From: "rickg%netscape.com" Date: Sun, 25 Jul 1999 17:21:34 +0000 Subject: [PATCH] odd 'n' ends git-svn-id: svn://10.0.0.236/trunk@41053 18797224-902f-48f8-a5cc-f745e15eee43 --- mozilla/string/obsolete/nsStr.cpp | 6 +- mozilla/string/obsolete/nsStr.h | 19 ++---- mozilla/xpcom/ds/bufferRoutines.h | 88 ++++++++++++++++--------- mozilla/xpcom/ds/nsStr.cpp | 6 +- mozilla/xpcom/ds/nsStr.h | 19 ++---- mozilla/xpcom/string/obsolete/nsStr.cpp | 6 +- mozilla/xpcom/string/obsolete/nsStr.h | 19 ++---- 7 files changed, 87 insertions(+), 76 deletions(-) diff --git a/mozilla/string/obsolete/nsStr.cpp b/mozilla/string/obsolete/nsStr.cpp index 784cbc73a5d..7e84a3b9705 100644 --- a/mozilla/string/obsolete/nsStr.cpp +++ b/mozilla/string/obsolete/nsStr.cpp @@ -651,7 +651,7 @@ PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor if(0=0) { PRUnichar theChar=GetCharAt(aDest,index); - thePos=gRFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase); + thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase); if(kNotFound!=thePos) return index; } //while @@ -691,7 +691,7 @@ PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PR //---------------------------------------------------------------------------------------- -CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { +CBufDescriptor::CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { mBuffer=aString; mCharSize=eOneByte; mStackBased=aStackBased; @@ -704,7 +704,7 @@ CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCa } } -CSharedStrBuffer::CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { +CBufDescriptor::CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { mBuffer=(char*)aString; mCharSize=eTwoByte; mStackBased=aStackBased; diff --git a/mozilla/string/obsolete/nsStr.h b/mozilla/string/obsolete/nsStr.h index 0802f394325..3f926f1807a 100644 --- a/mozilla/string/obsolete/nsStr.h +++ b/mozilla/string/obsolete/nsStr.h @@ -43,7 +43,7 @@ #define _nsStr #include "nscore.h" -#include "nsCppSharedAllocator.h" +#include "nsIAllocator.h" //---------------------------------------------------------------------------------------- @@ -60,10 +60,10 @@ class nsIMemoryAgent; //---------------------------------------------------------------------------------------- -class NS_COM CSharedStrBuffer { +class NS_COM CBufDescriptor { public: - CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); - CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); + CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); + CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); char* mBuffer; eCharSize mCharSize; @@ -311,11 +311,8 @@ public: } aDest.mCapacity=theNewCapacity++; - size_t theSize=(theNewCapacity< shared_allocator; - aDest.mStr = shared_allocator.allocate(theSize); + PRUint32 theSize=(theNewCapacity< shared_allocator; - shared_allocator.deallocate(aDest.mStr, aDest.mCapacity); + nsAllocator::Free(aDest.mStr); } aDest.mStr=0; aDest.mOwnsBuffer=0; diff --git a/mozilla/xpcom/ds/bufferRoutines.h b/mozilla/xpcom/ds/bufferRoutines.h index e9793b8f77f..2c2c72b61bf 100644 --- a/mozilla/xpcom/ds/bufferRoutines.h +++ b/mozilla/xpcom/ds/bufferRoutines.h @@ -1,4 +1,3 @@ - /* -*- Mode: C++; tab-width: 2; indent-tabs-mode: nil; c-basic-offset: 2 -*- */ /* * The contents of this file are subject to the Netscape Public License @@ -286,15 +285,21 @@ CopyChars gCopyChars[2][2]={ * @return index of pos if found, else -1 (kNotFound) */ inline PRInt32 FindChar1(const char* aDest,PRUint32 aLength,PRUint32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase) { - PRUnichar theCmpChar=(aIgnoreCase ? nsCRT::ToUpper(aChar) : aChar); PRInt32 theIndex=0; PRInt32 theLength=(PRInt32)aLength; - for(theIndex=(PRInt32)anOffset;theIndex=0;theIndex--){ - PRUnichar theChar=GetCharAt(aDest,theIndex); - if(aIgnoreCase) - theChar=nsCRT::ToUpper(theChar); - if(theChar==theCmpChar) - return theIndex; + + if(aIgnoreCase) { + PRUnichar theChar=nsCRT::ToUpper(aChar); + for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){ + if(nsCRT::ToUpper(aDest[theIndex])==theChar) + return theIndex; + } } + else { + for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){ + if(aDest[theIndex]==aChar) + return theIndex; + } + } + return kNotFound; } @@ -364,16 +382,24 @@ inline PRInt32 RFindChar1(const char* aDest,PRUint32 aDestLength,PRUint32 anOffs * @return index of pos if found, else -1 (kNotFound) */ inline PRInt32 RFindChar2(const char* aDest,PRUint32 aDestLength,PRUint32 anOffset,const PRUnichar aChar,PRBool aIgnoreCase) { - PRUnichar theCmpChar=(aIgnoreCase ? nsCRT::ToUpper(aChar) : aChar); + PRInt32 theIndex=0; - PRInt32 thePos=(PRInt32)anOffset; - for(theIndex=thePos;theIndex>=0;theIndex--){ - PRUnichar theChar=GetUnicharAt(aDest,theIndex); - if(aIgnoreCase) - theChar=nsCRT::ToUpper(theChar); - if(theChar==theCmpChar) - return theIndex; + PRUnichar* theBuf=(PRUnichar*)aDest; + + if(aIgnoreCase) { + PRUnichar theChar=nsCRT::ToUpper(aChar); + for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){ + if(nsCRT::ToUpper(theBuf[theIndex])==theChar) + return theIndex; + } } + else { + for(theIndex=(PRInt32)anOffset;theIndex>=0;theIndex--){ + if(theBuf[theIndex]==aChar) + return theIndex; + } + } + return kNotFound; } diff --git a/mozilla/xpcom/ds/nsStr.cpp b/mozilla/xpcom/ds/nsStr.cpp index 784cbc73a5d..7e84a3b9705 100644 --- a/mozilla/xpcom/ds/nsStr.cpp +++ b/mozilla/xpcom/ds/nsStr.cpp @@ -651,7 +651,7 @@ PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor if(0=0) { PRUnichar theChar=GetCharAt(aDest,index); - thePos=gRFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase); + thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase); if(kNotFound!=thePos) return index; } //while @@ -691,7 +691,7 @@ PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PR //---------------------------------------------------------------------------------------- -CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { +CBufDescriptor::CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { mBuffer=aString; mCharSize=eOneByte; mStackBased=aStackBased; @@ -704,7 +704,7 @@ CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCa } } -CSharedStrBuffer::CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { +CBufDescriptor::CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { mBuffer=(char*)aString; mCharSize=eTwoByte; mStackBased=aStackBased; diff --git a/mozilla/xpcom/ds/nsStr.h b/mozilla/xpcom/ds/nsStr.h index 0802f394325..3f926f1807a 100644 --- a/mozilla/xpcom/ds/nsStr.h +++ b/mozilla/xpcom/ds/nsStr.h @@ -43,7 +43,7 @@ #define _nsStr #include "nscore.h" -#include "nsCppSharedAllocator.h" +#include "nsIAllocator.h" //---------------------------------------------------------------------------------------- @@ -60,10 +60,10 @@ class nsIMemoryAgent; //---------------------------------------------------------------------------------------- -class NS_COM CSharedStrBuffer { +class NS_COM CBufDescriptor { public: - CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); - CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); + CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); + CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); char* mBuffer; eCharSize mCharSize; @@ -311,11 +311,8 @@ public: } aDest.mCapacity=theNewCapacity++; - size_t theSize=(theNewCapacity< shared_allocator; - aDest.mStr = shared_allocator.allocate(theSize); + PRUint32 theSize=(theNewCapacity< shared_allocator; - shared_allocator.deallocate(aDest.mStr, aDest.mCapacity); + nsAllocator::Free(aDest.mStr); } aDest.mStr=0; aDest.mOwnsBuffer=0; diff --git a/mozilla/xpcom/string/obsolete/nsStr.cpp b/mozilla/xpcom/string/obsolete/nsStr.cpp index 784cbc73a5d..7e84a3b9705 100644 --- a/mozilla/xpcom/string/obsolete/nsStr.cpp +++ b/mozilla/xpcom/string/obsolete/nsStr.cpp @@ -651,7 +651,7 @@ PRInt32 nsStr::RFindCharInSet(const nsStr& aDest,const nsStr& aSet,PRBool aIgnor if(0=0) { PRUnichar theChar=GetCharAt(aDest,index); - thePos=gRFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase); + thePos=gFindChars[aSet.mCharSize](aSet.mStr,aSet.mLength,0,theChar,aIgnoreCase); if(kNotFound!=thePos) return index; } //while @@ -691,7 +691,7 @@ PRInt32 nsStr::Compare(const nsStr& aDest,const nsStr& aSource,PRInt32 aCount,PR //---------------------------------------------------------------------------------------- -CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { +CBufDescriptor::CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { mBuffer=aString; mCharSize=eOneByte; mStackBased=aStackBased; @@ -704,7 +704,7 @@ CSharedStrBuffer::CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCa } } -CSharedStrBuffer::CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { +CBufDescriptor::CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength) { mBuffer=(char*)aString; mCharSize=eTwoByte; mStackBased=aStackBased; diff --git a/mozilla/xpcom/string/obsolete/nsStr.h b/mozilla/xpcom/string/obsolete/nsStr.h index 0802f394325..3f926f1807a 100644 --- a/mozilla/xpcom/string/obsolete/nsStr.h +++ b/mozilla/xpcom/string/obsolete/nsStr.h @@ -43,7 +43,7 @@ #define _nsStr #include "nscore.h" -#include "nsCppSharedAllocator.h" +#include "nsIAllocator.h" //---------------------------------------------------------------------------------------- @@ -60,10 +60,10 @@ class nsIMemoryAgent; //---------------------------------------------------------------------------------------- -class NS_COM CSharedStrBuffer { +class NS_COM CBufDescriptor { public: - CSharedStrBuffer(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); - CSharedStrBuffer(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); + CBufDescriptor(char* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); + CBufDescriptor(PRUnichar* aString,PRBool aStackBased,PRUint32 aCapacity,PRInt32 aLength=-1); char* mBuffer; eCharSize mCharSize; @@ -311,11 +311,8 @@ public: } aDest.mCapacity=theNewCapacity++; - size_t theSize=(theNewCapacity< shared_allocator; - aDest.mStr = shared_allocator.allocate(theSize); + PRUint32 theSize=(theNewCapacity< shared_allocator; - shared_allocator.deallocate(aDest.mStr, aDest.mCapacity); + nsAllocator::Free(aDest.mStr); } aDest.mStr=0; aDest.mOwnsBuffer=0;