зеркало из https://github.com/mozilla/pjs.git
fix for bug 108597 - move mOwnsBuffer and mCharSize into smaller variables to reduce nsStr's overall size
r=jag, sr=waterson
This commit is contained in:
Родитель
0234615ad0
Коммит
61f5ed73c5
|
@ -132,7 +132,7 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
|
|||
PRBool result=PR_TRUE;
|
||||
if(aNewLength>aDest.mCapacity) {
|
||||
nsStr theTempStr;
|
||||
nsStr::Initialize(theTempStr,aDest.mCharSize);
|
||||
nsStr::Initialize(theTempStr,eCharSize(aDest.mCharSize));
|
||||
|
||||
#ifndef NS_USE_OLD_STRING_ALLOCATION_STRATEGY
|
||||
// the new strategy is, allocate exact size, double on grows
|
||||
|
@ -232,7 +232,7 @@ void nsStr::StrInsert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PR
|
|||
|
||||
if(aDest.mLength+theLength > aDest.mCapacity) {
|
||||
nsStr theTempStr;
|
||||
nsStr::Initialize(theTempStr,aDest.mCharSize);
|
||||
nsStr::Initialize(theTempStr,eCharSize(aDest.mCharSize));
|
||||
|
||||
PRBool isBigEnough=EnsureCapacity(theTempStr,aDest.mLength+theLength); //grow the temp buffer to the right size
|
||||
|
||||
|
|
|
@ -455,14 +455,15 @@ struct NS_COM nsStr {
|
|||
|
||||
PRUint32 mLength;
|
||||
PRUint32 mCapacity;
|
||||
eCharSize mCharSize;
|
||||
PRBool mOwnsBuffer;
|
||||
|
||||
|
||||
union {
|
||||
char* mStr;
|
||||
PRUnichar* mUStr;
|
||||
};
|
||||
|
||||
PRInt8 mCharSize;
|
||||
PRPackedBool mOwnsBuffer;
|
||||
|
||||
private:
|
||||
static PRBool Alloc(nsStr& aString,PRUint32 aCount);
|
||||
static PRBool Realloc(nsStr& aString,PRUint32 aCount);
|
||||
|
|
|
@ -114,7 +114,7 @@ nsCString::nsCString(const nsStr &aString) {
|
|||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString::nsCString(const nsCString& aString) {
|
||||
Initialize(*this,aString.mCharSize);
|
||||
Initialize(*this,eCharSize(aString.mCharSize));
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
|
||||
|
|
|
@ -132,7 +132,7 @@ PRBool nsStr::GrowCapacity(nsStr& aDest,PRUint32 aNewLength) {
|
|||
PRBool result=PR_TRUE;
|
||||
if(aNewLength>aDest.mCapacity) {
|
||||
nsStr theTempStr;
|
||||
nsStr::Initialize(theTempStr,aDest.mCharSize);
|
||||
nsStr::Initialize(theTempStr,eCharSize(aDest.mCharSize));
|
||||
|
||||
#ifndef NS_USE_OLD_STRING_ALLOCATION_STRATEGY
|
||||
// the new strategy is, allocate exact size, double on grows
|
||||
|
@ -232,7 +232,7 @@ void nsStr::StrInsert( nsStr& aDest,PRUint32 aDestOffset,const nsStr& aSource,PR
|
|||
|
||||
if(aDest.mLength+theLength > aDest.mCapacity) {
|
||||
nsStr theTempStr;
|
||||
nsStr::Initialize(theTempStr,aDest.mCharSize);
|
||||
nsStr::Initialize(theTempStr,eCharSize(aDest.mCharSize));
|
||||
|
||||
PRBool isBigEnough=EnsureCapacity(theTempStr,aDest.mLength+theLength); //grow the temp buffer to the right size
|
||||
|
||||
|
|
|
@ -455,14 +455,15 @@ struct NS_COM nsStr {
|
|||
|
||||
PRUint32 mLength;
|
||||
PRUint32 mCapacity;
|
||||
eCharSize mCharSize;
|
||||
PRBool mOwnsBuffer;
|
||||
|
||||
|
||||
union {
|
||||
char* mStr;
|
||||
PRUnichar* mUStr;
|
||||
};
|
||||
|
||||
PRInt8 mCharSize;
|
||||
PRPackedBool mOwnsBuffer;
|
||||
|
||||
private:
|
||||
static PRBool Alloc(nsStr& aString,PRUint32 aCount);
|
||||
static PRBool Realloc(nsStr& aString,PRUint32 aCount);
|
||||
|
|
|
@ -114,7 +114,7 @@ nsCString::nsCString(const nsStr &aString) {
|
|||
* @param reference to another nsCString
|
||||
*/
|
||||
nsCString::nsCString(const nsCString& aString) {
|
||||
Initialize(*this,aString.mCharSize);
|
||||
Initialize(*this,eCharSize(aString.mCharSize));
|
||||
StrAssign(*this,aString,0,aString.mLength);
|
||||
}
|
||||
|
||||
|
|
Загрузка…
Ссылка в новой задаче