reduce bloat by not chunk-allocating strings (in |nsStr::Alloc|). Clients that don't benefit from this can explicitly call |SetCapacity|. We may re-introduce this functionality in the append of a single character when no space remains, if it turns out to be a problem. This optimization was suggested by profiling done by sfraser, who now promises to find out where it hurts us.
git-svn-id: svn://10.0.0.236/trunk@72019 18797224-902f-48f8-a5cc-f745e15eee43
This commit is contained in:
@@ -656,6 +656,7 @@ PRBool nsStr::Alloc(nsStr& aDest,PRUint32 aCount) {
|
||||
static int mAllocCount=0;
|
||||
mAllocCount++;
|
||||
|
||||
#ifdef NS_USE_CHUNKY_STRING_ALLOCATION
|
||||
//we're given the acount value in charunits; now scale up to next multiple.
|
||||
PRUint32 theNewCapacity=kDefaultStringSize;
|
||||
while(theNewCapacity<aCount){
|
||||
@@ -665,6 +666,10 @@ PRBool nsStr::Alloc(nsStr& aDest,PRUint32 aCount) {
|
||||
aDest.mCapacity=theNewCapacity++;
|
||||
PRUint32 theSize=(theNewCapacity<<aDest.mCharSize);
|
||||
aDest.mStr = (char*)nsMemory::Alloc(theSize);
|
||||
#else
|
||||
aDest.mCapacity = aCount;
|
||||
aDest.mStr = (char*)nsMemory::Alloc((aCount+1)<<aDest.mCharSize);
|
||||
#endif
|
||||
|
||||
if(aDest.mStr) {
|
||||
aDest.mOwnsBuffer=1;
|
||||
|
||||
Reference in New Issue
Block a user