try to improve append performance and allow non-null term buffers when count is given

This commit is contained in:
rickg%netscape.com 1999-07-20 06:58:41 +00:00
parent 249234cbb3
commit bbf641cba9
16 changed files with 216 additions and 137 deletions

View File

@ -36,8 +36,8 @@
static const char* kFoolMsg = "Error: Some fool overwrote the shared buffer.";
static const char* kCallFindChar = "For better performance, call FindChar() for targets whose length==1.";
static const char* kCallRFindChar = "For better performance, call RFindChar() for targets whose length==1.";
//static const char* kCallFindChar = "For better performance, call FindChar() for targets whose length==1.";
//static const char* kCallRFindChar = "For better performance, call RFindChar() for targets whose length==1.";
//----------------------------------------------------------------------------------------
// The following is a memory agent who knows how to recycled (pool) freed memory...

View File

@ -645,7 +645,7 @@ PRInt32 _ToInteger(nsCString& aString,PRInt32* anErrorCode,PRUint32 aRadix) {
char theChar=0;
char theDigit=0;
while(--cp>=aString.mStr){
char theChar=*cp;
theChar=*cp;
if((theChar>='0') && (theChar<='9')){
theDigit=theChar-'0';
}
@ -899,7 +899,8 @@ nsCString& nsCString::Append(const nsStr& aString,PRInt32 aCount) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
@ -907,10 +908,11 @@ nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -921,7 +923,8 @@ nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
* append given uni-string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsCString& nsCString::Append(const PRUnichar* aString,PRInt32 aCount) {
@ -929,10 +932,11 @@ nsCString& nsCString::Append(const PRUnichar* aString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -1082,6 +1086,8 @@ nsCString& nsCString::Insert(const nsStr& aCopy,PRUint32 anOffset,PRInt32 aCount
* @update gess4/22/98
* @param aChar char to be inserted into this string
* @param anOffset is insert pos in str
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
@ -1089,10 +1095,11 @@ nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCou
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}
@ -1109,6 +1116,8 @@ nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCou
* @update gess4/22/98
* @param aChar char to be inserted into this string
* @param anOffset is insert pos in str
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsCString& nsCString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32 aCount){
@ -1116,10 +1125,11 @@ nsCString& nsCString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32
nsStr temp;
nsStr::Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}

View File

@ -439,7 +439,8 @@ nsCString& Append(const nsCString& aString) {return Append(aString,aString.mLeng
* Appends n characters from given string to this,
*
* @param aString is the source to be appended to this
* @param aCount -- number of chars to copy
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars copied
*/
nsCString& Append(const nsStr& aString,PRInt32 aCount);
@ -490,7 +491,8 @@ PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
*
* @param aCopy -- String to be inserted into this
* @param anOffset -- insertion position within this str
* @param aCount -- number of chars to be copied from aCopy
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars inserted into this.
*/
nsCString& Insert(const nsStr& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
@ -501,6 +503,8 @@ nsCString& Insert(const nsStr& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
*
* @param aString* to be inserted into this string
* @param anOffset is insert pos in str
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsCString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
@ -514,7 +518,6 @@ nsCString& Insert(const PRUnichar* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
* @param anOffset is insert pos in str
* @return the number of chars inserted into this string
*/
//nsCString& Insert(char aChar,PRUint32 anOffset);
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset);
/*

View File

@ -951,6 +951,8 @@ nsString& nsString::operator=(const nsSubsumeStr& aSubsumeString) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
@ -969,6 +971,8 @@ nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
@ -984,7 +988,8 @@ nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
@ -992,10 +997,11 @@ nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -1006,7 +1012,8 @@ nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
* append given uni-string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
@ -1014,10 +1021,11 @@ nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -1160,7 +1168,8 @@ PRUint32 nsString::Right(nsString& aCopy,PRInt32 aCount) const{
* @update gess 4/1/98
* @param aCopy -- String to be inserted into this
* @param anOffset -- insertion position within this str
* @param aCount -- number of chars to be copied from aCopy
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars inserted into this.
*/
nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) {
@ -1175,7 +1184,8 @@ nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCoun
* @update gess4/22/98
* @param aChar char to be inserted into this string
* @param anOffset is insert pos in str
* @param aCounttells us how many chars to insert
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
@ -1183,10 +1193,11 @@ nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}
@ -1209,10 +1220,11 @@ nsString& nsString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32 aC
nsStr temp;
nsStr::Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}

View File

@ -446,7 +446,8 @@ nsString& Append(const nsString& aString) {return Append(aString,aString.mLength
* Appends n characters from given string to this,
*
* @param aString is the source to be appended to this
* @param aCount -- number of chars to copy
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars copied
*/
nsString& Append(const nsStr& aString,PRInt32 aCount);

View File

@ -1,3 +1,4 @@
/* -*- 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
@ -64,7 +65,7 @@ inline PRUnichar GetCharAt(const char* aString,PRUint32 anIndex) {
* @param aCount is the number of chars to be "cut"
*/
void ShiftCharsLeft(char* aDest,PRUint32 aLength,PRUint32 anOffset,PRUint32 aCount) {
PRUint32 theMax=aLength-anOffset;
//PRUint32 theMax=aLength-anOffset;
//PRUint32 theLength=(theMax<aCount) ? theMax : aCount;
char* first= aDest+anOffset+aCount;
@ -109,7 +110,7 @@ void ShiftCharsRight(char* aDest,PRUint32 aLength,PRUint32 anOffset,PRUint32 aCo
* @param aCount is the number of chars to be "cut"
*/
void ShiftDoubleCharsLeft(char* aDest,PRUint32 aLength,PRUint32 anOffset,PRUint32 aCount) {
PRUint32 theMax=aLength-anOffset;
//PRUint32 theMax=aLength-anOffset;
//PRUint32 theLength=(theMax<aCount) ? theMax : aCount;
PRUnichar* theBuf=(PRUnichar*)aDest;

View File

@ -36,8 +36,8 @@
static const char* kFoolMsg = "Error: Some fool overwrote the shared buffer.";
static const char* kCallFindChar = "For better performance, call FindChar() for targets whose length==1.";
static const char* kCallRFindChar = "For better performance, call RFindChar() for targets whose length==1.";
//static const char* kCallFindChar = "For better performance, call FindChar() for targets whose length==1.";
//static const char* kCallRFindChar = "For better performance, call RFindChar() for targets whose length==1.";
//----------------------------------------------------------------------------------------
// The following is a memory agent who knows how to recycled (pool) freed memory...

View File

@ -645,7 +645,7 @@ PRInt32 _ToInteger(nsCString& aString,PRInt32* anErrorCode,PRUint32 aRadix) {
char theChar=0;
char theDigit=0;
while(--cp>=aString.mStr){
char theChar=*cp;
theChar=*cp;
if((theChar>='0') && (theChar<='9')){
theDigit=theChar-'0';
}
@ -899,7 +899,8 @@ nsCString& nsCString::Append(const nsStr& aString,PRInt32 aCount) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
@ -907,10 +908,11 @@ nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -921,7 +923,8 @@ nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
* append given uni-string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsCString& nsCString::Append(const PRUnichar* aString,PRInt32 aCount) {
@ -929,10 +932,11 @@ nsCString& nsCString::Append(const PRUnichar* aString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -1082,6 +1086,8 @@ nsCString& nsCString::Insert(const nsStr& aCopy,PRUint32 anOffset,PRInt32 aCount
* @update gess4/22/98
* @param aChar char to be inserted into this string
* @param anOffset is insert pos in str
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
@ -1089,10 +1095,11 @@ nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCou
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}
@ -1109,6 +1116,8 @@ nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCou
* @update gess4/22/98
* @param aChar char to be inserted into this string
* @param anOffset is insert pos in str
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsCString& nsCString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32 aCount){
@ -1116,10 +1125,11 @@ nsCString& nsCString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32
nsStr temp;
nsStr::Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}

View File

@ -439,7 +439,8 @@ nsCString& Append(const nsCString& aString) {return Append(aString,aString.mLeng
* Appends n characters from given string to this,
*
* @param aString is the source to be appended to this
* @param aCount -- number of chars to copy
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars copied
*/
nsCString& Append(const nsStr& aString,PRInt32 aCount);
@ -490,7 +491,8 @@ PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
*
* @param aCopy -- String to be inserted into this
* @param anOffset -- insertion position within this str
* @param aCount -- number of chars to be copied from aCopy
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars inserted into this.
*/
nsCString& Insert(const nsStr& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
@ -501,6 +503,8 @@ nsCString& Insert(const nsStr& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
*
* @param aString* to be inserted into this string
* @param anOffset is insert pos in str
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsCString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
@ -514,7 +518,6 @@ nsCString& Insert(const PRUnichar* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
* @param anOffset is insert pos in str
* @return the number of chars inserted into this string
*/
//nsCString& Insert(char aChar,PRUint32 anOffset);
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset);
/*

View File

@ -951,6 +951,8 @@ nsString& nsString::operator=(const nsSubsumeStr& aSubsumeString) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
@ -969,6 +971,8 @@ nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
@ -984,7 +988,8 @@ nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
@ -992,10 +997,11 @@ nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -1006,7 +1012,8 @@ nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
* append given uni-string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
@ -1014,10 +1021,11 @@ nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -1160,7 +1168,8 @@ PRUint32 nsString::Right(nsString& aCopy,PRInt32 aCount) const{
* @update gess 4/1/98
* @param aCopy -- String to be inserted into this
* @param anOffset -- insertion position within this str
* @param aCount -- number of chars to be copied from aCopy
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars inserted into this.
*/
nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) {
@ -1175,7 +1184,8 @@ nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCoun
* @update gess4/22/98
* @param aChar char to be inserted into this string
* @param anOffset is insert pos in str
* @param aCounttells us how many chars to insert
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
@ -1183,10 +1193,11 @@ nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}
@ -1209,10 +1220,11 @@ nsString& nsString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32 aC
nsStr temp;
nsStr::Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}

View File

@ -446,7 +446,8 @@ nsString& Append(const nsString& aString) {return Append(aString,aString.mLength
* Appends n characters from given string to this,
*
* @param aString is the source to be appended to this
* @param aCount -- number of chars to copy
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars copied
*/
nsString& Append(const nsStr& aString,PRInt32 aCount);

View File

@ -36,8 +36,8 @@
static const char* kFoolMsg = "Error: Some fool overwrote the shared buffer.";
static const char* kCallFindChar = "For better performance, call FindChar() for targets whose length==1.";
static const char* kCallRFindChar = "For better performance, call RFindChar() for targets whose length==1.";
//static const char* kCallFindChar = "For better performance, call FindChar() for targets whose length==1.";
//static const char* kCallRFindChar = "For better performance, call RFindChar() for targets whose length==1.";
//----------------------------------------------------------------------------------------
// The following is a memory agent who knows how to recycled (pool) freed memory...

View File

@ -645,7 +645,7 @@ PRInt32 _ToInteger(nsCString& aString,PRInt32* anErrorCode,PRUint32 aRadix) {
char theChar=0;
char theDigit=0;
while(--cp>=aString.mStr){
char theChar=*cp;
theChar=*cp;
if((theChar>='0') && (theChar<='9')){
theDigit=theChar-'0';
}
@ -899,7 +899,8 @@ nsCString& nsCString::Append(const nsStr& aString,PRInt32 aCount) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
@ -907,10 +908,11 @@ nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -921,7 +923,8 @@ nsCString& nsCString::Append(const char* aCString,PRInt32 aCount) {
* append given uni-string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsCString& nsCString::Append(const PRUnichar* aString,PRInt32 aCount) {
@ -929,10 +932,11 @@ nsCString& nsCString::Append(const PRUnichar* aString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -1082,6 +1086,8 @@ nsCString& nsCString::Insert(const nsStr& aCopy,PRUint32 anOffset,PRInt32 aCount
* @update gess4/22/98
* @param aChar char to be inserted into this string
* @param anOffset is insert pos in str
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
@ -1089,10 +1095,11 @@ nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCou
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}
@ -1109,6 +1116,8 @@ nsCString& nsCString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCou
* @update gess4/22/98
* @param aChar char to be inserted into this string
* @param anOffset is insert pos in str
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsCString& nsCString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32 aCount){
@ -1116,10 +1125,11 @@ nsCString& nsCString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32
nsStr temp;
nsStr::Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}

View File

@ -439,7 +439,8 @@ nsCString& Append(const nsCString& aString) {return Append(aString,aString.mLeng
* Appends n characters from given string to this,
*
* @param aString is the source to be appended to this
* @param aCount -- number of chars to copy
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars copied
*/
nsCString& Append(const nsStr& aString,PRInt32 aCount);
@ -490,7 +491,8 @@ PRUint32 Right(nsCString& aCopy,PRInt32 aCount) const;
*
* @param aCopy -- String to be inserted into this
* @param anOffset -- insertion position within this str
* @param aCount -- number of chars to be copied from aCopy
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars inserted into this.
*/
nsCString& Insert(const nsStr& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
@ -501,6 +503,8 @@ nsCString& Insert(const nsStr& aCopy,PRUint32 anOffset,PRInt32 aCount=-1);
*
* @param aString* to be inserted into this string
* @param anOffset is insert pos in str
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsCString& Insert(const char* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
@ -514,7 +518,6 @@ nsCString& Insert(const PRUnichar* aChar,PRUint32 anOffset,PRInt32 aCount=-1);
* @param anOffset is insert pos in str
* @return the number of chars inserted into this string
*/
//nsCString& Insert(char aChar,PRUint32 anOffset);
nsCString& Insert(PRUnichar aChar,PRUint32 anOffset);
/*

View File

@ -951,6 +951,8 @@ nsString& nsString::operator=(const nsSubsumeStr& aSubsumeString) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
@ -969,6 +971,8 @@ nsString& nsString::Append(const nsStr& aString,PRInt32 aCount) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
@ -984,7 +988,8 @@ nsString& nsString::Append(const nsString& aString,PRInt32 aCount) {
* append given string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
@ -992,10 +997,11 @@ nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -1006,7 +1012,8 @@ nsString& nsString::Append(const char* aCString,PRInt32 aCount) {
* append given uni-string to this string
* @update gess 01/04/99
* @param aString : string to be appended to this
* @param aCount: #of chars to be copied
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return this
*/
nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
@ -1014,10 +1021,11 @@ nsString& nsString::Append(const PRUnichar* aString,PRInt32 aCount) {
nsStr temp;
Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(0<aCount)
nsStr::Append(*this,temp,0,aCount,mAgent);
}
@ -1160,7 +1168,8 @@ PRUint32 nsString::Right(nsString& aCopy,PRInt32 aCount) const{
* @update gess 4/1/98
* @param aCopy -- String to be inserted into this
* @param anOffset -- insertion position within this str
* @param aCount -- number of chars to be copied from aCopy
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars inserted into this.
*/
nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCount) {
@ -1175,7 +1184,8 @@ nsString& nsString::Insert(const nsString& aCopy,PRUint32 anOffset,PRInt32 aCoun
* @update gess4/22/98
* @param aChar char to be inserted into this string
* @param anOffset is insert pos in str
* @param aCounttells us how many chars to insert
* @param aCount -- number of chars to insert; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return the number of chars inserted into this string
*/
nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount){
@ -1183,10 +1193,11 @@ nsString& nsString::Insert(const char* aCString,PRUint32 anOffset,PRInt32 aCount
nsStr temp;
nsStr::Initialize(temp,eOneByte);
temp.mStr=(char*)aCString;
temp.mLength=nsCRT::strlen(aCString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aCString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}
@ -1209,10 +1220,11 @@ nsString& nsString::Insert(const PRUnichar* aString,PRUint32 anOffset,PRInt32 aC
nsStr temp;
nsStr::Initialize(temp,eTwoByte);
temp.mUStr=(PRUnichar*)aString;
temp.mLength=nsCRT::strlen(aString);
if(aCount<0)
aCount=temp.mLength;
else aCount=MinInt(aCount,temp.mLength);
if(aCount<0)
aCount=temp.mLength=nsCRT::strlen(aString);
else temp.mLength=aCount;
if(temp.mLength && (0<aCount)){
nsStr::Insert(*this,anOffset,temp,0,aCount,0);
}

View File

@ -446,7 +446,8 @@ nsString& Append(const nsString& aString) {return Append(aString,aString.mLength
* Appends n characters from given string to this,
*
* @param aString is the source to be appended to this
* @param aCount -- number of chars to copy
* @param aCount -- number of chars to copy; -1 tells us to compute the strlen for you
* WARNING: If you provide a count>0, we don't double check the actual string length!
* @return number of chars copied
*/
nsString& Append(const nsStr& aString,PRInt32 aCount);