зеркало из https://github.com/mozilla/gecko-dev.git
fixed bug in nsString; added recycler to nsString2
This commit is contained in:
Родитель
9adc279405
Коммит
a313d5394a
|
@ -1097,6 +1097,7 @@ PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) const {
|
|||
* @return number of chars copied
|
||||
*/
|
||||
PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const {
|
||||
aCopy.Truncate();
|
||||
if(anOffset<mLength) {
|
||||
aCount=(anOffset+aCount<=mLength) ? aCount : mLength-anOffset;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nsISizeOfHandler.h"
|
||||
#include "prprf.h"
|
||||
#include "prdtoa.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
#include "nsUnicharUtilCIID.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -1567,6 +1568,64 @@ PRBool nsString2::IsDigit(PRUnichar aChar) {
|
|||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* This class, appropriately enough, creates and recycles nsString2 objects..
|
||||
****************************************************************************/
|
||||
|
||||
#if 0
|
||||
|
||||
class nsStringRecycler {
|
||||
public:
|
||||
nsStringRecycler() : mDeque(0) {
|
||||
}
|
||||
|
||||
void Recycle(nsString2* aString) {
|
||||
mDeque.Push(aString);
|
||||
}
|
||||
|
||||
nsString2* NewString(eCharSize aCharSize){
|
||||
nsString2* result=(nsString2*)mDeque.Pop();
|
||||
if(!result)
|
||||
result=new nsString2(aCharSize);
|
||||
return result;
|
||||
}
|
||||
nsDeque mDeque;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsStringRecycler& GetRecycler(void){
|
||||
static nsStringRecycler gRecycler;
|
||||
return gRecycler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this mehod when you're done
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsString2* nsString2::NewString(eCharSize aCharSize){
|
||||
nsString2* result=GetRecycler().NewString(aCharSize);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this mehod when you're done
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsString2::Recycle(nsString2* aString){
|
||||
GetRecycler().Recycle(aString);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
|
|
|
@ -675,6 +675,10 @@ static PRBool IsAlpha(PRUnichar ch);
|
|||
*/
|
||||
static PRBool IsDigit(PRUnichar ch);
|
||||
|
||||
#if 0
|
||||
static void Recycle(nsString2* aString);
|
||||
static nsString2* NewString(eCharSize aCharSize=eTwoByte);
|
||||
#endif
|
||||
|
||||
static void SelfTest();
|
||||
virtual void DebugDump(ostream& aStream) const;
|
||||
|
|
|
@ -1097,6 +1097,7 @@ PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) const {
|
|||
* @return number of chars copied
|
||||
*/
|
||||
PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const {
|
||||
aCopy.Truncate();
|
||||
if(anOffset<mLength) {
|
||||
aCount=(anOffset+aCount<=mLength) ? aCount : mLength-anOffset;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nsISizeOfHandler.h"
|
||||
#include "prprf.h"
|
||||
#include "prdtoa.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
#include "nsUnicharUtilCIID.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -1567,6 +1568,64 @@ PRBool nsString2::IsDigit(PRUnichar aChar) {
|
|||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* This class, appropriately enough, creates and recycles nsString2 objects..
|
||||
****************************************************************************/
|
||||
|
||||
#if 0
|
||||
|
||||
class nsStringRecycler {
|
||||
public:
|
||||
nsStringRecycler() : mDeque(0) {
|
||||
}
|
||||
|
||||
void Recycle(nsString2* aString) {
|
||||
mDeque.Push(aString);
|
||||
}
|
||||
|
||||
nsString2* NewString(eCharSize aCharSize){
|
||||
nsString2* result=(nsString2*)mDeque.Pop();
|
||||
if(!result)
|
||||
result=new nsString2(aCharSize);
|
||||
return result;
|
||||
}
|
||||
nsDeque mDeque;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsStringRecycler& GetRecycler(void){
|
||||
static nsStringRecycler gRecycler;
|
||||
return gRecycler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this mehod when you're done
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsString2* nsString2::NewString(eCharSize aCharSize){
|
||||
nsString2* result=GetRecycler().NewString(aCharSize);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this mehod when you're done
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsString2::Recycle(nsString2* aString){
|
||||
GetRecycler().Recycle(aString);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
|
|
|
@ -675,6 +675,10 @@ static PRBool IsAlpha(PRUnichar ch);
|
|||
*/
|
||||
static PRBool IsDigit(PRUnichar ch);
|
||||
|
||||
#if 0
|
||||
static void Recycle(nsString2* aString);
|
||||
static nsString2* NewString(eCharSize aCharSize=eTwoByte);
|
||||
#endif
|
||||
|
||||
static void SelfTest();
|
||||
virtual void DebugDump(ostream& aStream) const;
|
||||
|
|
|
@ -1097,6 +1097,7 @@ PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) const {
|
|||
* @return number of chars copied
|
||||
*/
|
||||
PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const {
|
||||
aCopy.Truncate();
|
||||
if(anOffset<mLength) {
|
||||
aCount=(anOffset+aCount<=mLength) ? aCount : mLength-anOffset;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nsISizeOfHandler.h"
|
||||
#include "prprf.h"
|
||||
#include "prdtoa.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
#include "nsUnicharUtilCIID.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -1567,6 +1568,64 @@ PRBool nsString2::IsDigit(PRUnichar aChar) {
|
|||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* This class, appropriately enough, creates and recycles nsString2 objects..
|
||||
****************************************************************************/
|
||||
|
||||
#if 0
|
||||
|
||||
class nsStringRecycler {
|
||||
public:
|
||||
nsStringRecycler() : mDeque(0) {
|
||||
}
|
||||
|
||||
void Recycle(nsString2* aString) {
|
||||
mDeque.Push(aString);
|
||||
}
|
||||
|
||||
nsString2* NewString(eCharSize aCharSize){
|
||||
nsString2* result=(nsString2*)mDeque.Pop();
|
||||
if(!result)
|
||||
result=new nsString2(aCharSize);
|
||||
return result;
|
||||
}
|
||||
nsDeque mDeque;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsStringRecycler& GetRecycler(void){
|
||||
static nsStringRecycler gRecycler;
|
||||
return gRecycler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this mehod when you're done
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsString2* nsString2::NewString(eCharSize aCharSize){
|
||||
nsString2* result=GetRecycler().NewString(aCharSize);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this mehod when you're done
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsString2::Recycle(nsString2* aString){
|
||||
GetRecycler().Recycle(aString);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
|
|
|
@ -675,6 +675,10 @@ static PRBool IsAlpha(PRUnichar ch);
|
|||
*/
|
||||
static PRBool IsDigit(PRUnichar ch);
|
||||
|
||||
#if 0
|
||||
static void Recycle(nsString2* aString);
|
||||
static nsString2* NewString(eCharSize aCharSize=eTwoByte);
|
||||
#endif
|
||||
|
||||
static void SelfTest();
|
||||
virtual void DebugDump(ostream& aStream) const;
|
||||
|
|
|
@ -1097,6 +1097,7 @@ PRInt32 nsString::Left(nsString& aCopy,PRInt32 aCount) const {
|
|||
* @return number of chars copied
|
||||
*/
|
||||
PRInt32 nsString::Mid(nsString& aCopy,PRInt32 anOffset,PRInt32 aCount) const {
|
||||
aCopy.Truncate();
|
||||
if(anOffset<mLength) {
|
||||
aCount=(anOffset+aCount<=mLength) ? aCount : mLength-anOffset;
|
||||
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
#include "nsISizeOfHandler.h"
|
||||
#include "prprf.h"
|
||||
#include "prdtoa.h"
|
||||
#include "nsDeque.h"
|
||||
|
||||
#include "nsUnicharUtilCIID.h"
|
||||
#include "nsIServiceManager.h"
|
||||
|
@ -1567,6 +1568,64 @@ PRBool nsString2::IsDigit(PRUnichar aChar) {
|
|||
}
|
||||
|
||||
|
||||
/****************************************************************************
|
||||
* This class, appropriately enough, creates and recycles nsString2 objects..
|
||||
****************************************************************************/
|
||||
|
||||
#if 0
|
||||
|
||||
class nsStringRecycler {
|
||||
public:
|
||||
nsStringRecycler() : mDeque(0) {
|
||||
}
|
||||
|
||||
void Recycle(nsString2* aString) {
|
||||
mDeque.Push(aString);
|
||||
}
|
||||
|
||||
nsString2* NewString(eCharSize aCharSize){
|
||||
nsString2* result=(nsString2*)mDeque.Pop();
|
||||
if(!result)
|
||||
result=new nsString2(aCharSize);
|
||||
return result;
|
||||
}
|
||||
nsDeque mDeque;
|
||||
};
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsStringRecycler& GetRecycler(void){
|
||||
static nsStringRecycler gRecycler;
|
||||
return gRecycler;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this mehod when you're done
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
nsString2* nsString2::NewString(eCharSize aCharSize){
|
||||
nsString2* result=GetRecycler().NewString(aCharSize);
|
||||
return result;
|
||||
}
|
||||
|
||||
/**
|
||||
* Call this mehod when you're done
|
||||
* @update gess 01/04/99
|
||||
* @param
|
||||
* @return
|
||||
*/
|
||||
void nsString2::Recycle(nsString2* aString){
|
||||
GetRecycler().Recycle(aString);
|
||||
}
|
||||
|
||||
#endif
|
||||
|
||||
/**
|
||||
*
|
||||
* @update gess 01/04/99
|
||||
|
|
|
@ -675,6 +675,10 @@ static PRBool IsAlpha(PRUnichar ch);
|
|||
*/
|
||||
static PRBool IsDigit(PRUnichar ch);
|
||||
|
||||
#if 0
|
||||
static void Recycle(nsString2* aString);
|
||||
static nsString2* NewString(eCharSize aCharSize=eTwoByte);
|
||||
#endif
|
||||
|
||||
static void SelfTest();
|
||||
virtual void DebugDump(ostream& aStream) const;
|
||||
|
|
Загрузка…
Ссылка в новой задаче