Checking in jeff.qiu@sun.com's fix for bug 77585. Speeding up nsGenericDOMDataNode::AppendData(). r=cbiesinger@web.de, sr=jst@netscape.com

This commit is contained in:
jst%netscape.com 2002-04-10 21:44:04 +00:00
Родитель 02053b1466
Коммит eafd961a01
4 изменённых файлов: 39 добавлений и 5 удалений

Просмотреть файл

@ -500,12 +500,22 @@ nsGenericDOMDataNode::AppendData(const nsAString& aData)
{
#if 1
nsresult rv = NS_OK;
PRInt32 length = 0;
nsAutoString old_data;
// See bugzilla bug 77585.
if (mText.Is2b() || (!IsASCII(aData))) {
nsAutoString old_data;
mText.AppendTo(old_data);
length = old_data.Length();
rv = SetText(old_data + aData, PR_FALSE);
} else {
nsCAutoString old_data;
mText.AppendTo(old_data);
length = old_data.Length();
old_data.AppendWithConversion(aData);
rv = SetText(old_data.get(), old_data.Length(), PR_FALSE);
}
mText.AppendTo(old_data);
rv = SetText(old_data + aData, PR_FALSE);
NS_ENSURE_SUCCESS(rv, rv);
// Trigger a reflow
@ -516,7 +526,7 @@ nsGenericDOMDataNode::AppendData(const nsAString& aData)
nsTextContentChangeData* tccd = nsnull;
rv = NS_NewTextContentChangeData(&tccd);
if (NS_SUCCEEDED(rv)) {
tccd->SetData(nsITextContentChangeData::Append, old_data.Length(),
tccd->SetData(nsITextContentChangeData::Append, length,
aData.Length());
rv = mDocument->ContentChanged(this, tccd);
NS_RELEASE(tccd);

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsAString.h"
class nsString;
class nsCString;
// XXX should this normalize the code to keep a \u0000 at the end?
@ -205,6 +206,11 @@ public:
*/
void AppendTo(nsString& aString) const;
/**
* Append the contents of this string fragment to aCString
*/
void AppendTo(nsCString& aCString) const;
/**
* Make a copy of the fragments contents starting at offset for
* count characters. The offset and count will be adjusted to

Просмотреть файл

@ -40,6 +40,7 @@
#include "nsAString.h"
class nsString;
class nsCString;
// XXX should this normalize the code to keep a \u0000 at the end?
@ -205,6 +206,11 @@ public:
*/
void AppendTo(nsString& aString) const;
/**
* Append the contents of this string fragment to aCString
*/
void AppendTo(nsCString& aCString) const;
/**
* Make a copy of the fragments contents starting at offset for
* count characters. The offset and count will be adjusted to

Просмотреть файл

@ -278,6 +278,18 @@ nsTextFragment::AppendTo(nsString& aString) const
}
}
void
nsTextFragment::AppendTo(nsCString& aCString) const
{
if (mState.mLength == 0) return;
if (mState.mIs2b) {
aCString.AppendWithConversion((PRUnichar *)m2b, mState.mLength);
} else {
aCString.Append((char *)m1b, mState.mLength);
}
}
void
nsTextFragment::CopyTo(PRUnichar *aDest, PRInt32 aOffset, PRInt32 aCount)
{