eliminate extra string copy

This commit is contained in:
rickg%netscape.com 2000-03-12 10:52:02 +00:00
parent 6d722b2ecd
commit 16905de361
2 changed files with 14 additions and 8 deletions

View File

@ -155,8 +155,7 @@ nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
//this little piece of code exists because entities may or may not have the terminating ';'.
//if we see it, strip if off for this test...
PRUnichar theLastChar=GetCharAt(aEntity,aEntity.mLength-1);
if(';'==theLastChar) {
if(';'==aEntity.Last()) {
nsCAutoString temp(aEntity);
temp.Truncate(aEntity.mLength-1);
return EntityToUnicode(temp);
@ -177,10 +176,14 @@ nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
PRInt32
nsHTMLEntities::EntityToUnicode(const nsString& aEntity) {
nsCAutoString theEntity(aEntity);
PRInt32 result=EntityToUnicode(theEntity);
return result;
if(';'==theEntity.Last()) {
theEntity.Truncate(theEntity.Length()-1);
}
return EntityToUnicode(theEntity);
}
const nsCString&
nsHTMLEntities::UnicodeToEntity(PRInt32 aUnicode)
{

View File

@ -155,8 +155,7 @@ nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
//this little piece of code exists because entities may or may not have the terminating ';'.
//if we see it, strip if off for this test...
PRUnichar theLastChar=GetCharAt(aEntity,aEntity.mLength-1);
if(';'==theLastChar) {
if(';'==aEntity.Last()) {
nsCAutoString temp(aEntity);
temp.Truncate(aEntity.mLength-1);
return EntityToUnicode(temp);
@ -177,10 +176,14 @@ nsHTMLEntities::EntityToUnicode(const nsCString& aEntity)
PRInt32
nsHTMLEntities::EntityToUnicode(const nsString& aEntity) {
nsCAutoString theEntity(aEntity);
PRInt32 result=EntityToUnicode(theEntity);
return result;
if(';'==theEntity.Last()) {
theEntity.Truncate(theEntity.Length()-1);
}
return EntityToUnicode(theEntity);
}
const nsCString&
nsHTMLEntities::UnicodeToEntity(PRInt32 aUnicode)
{