mirror of
https://repo.dactyloidae.xyz/Dactyloidae/UXP.git
synced 2026-09-04 06:48:38 +09:00
Introduce a new non-heap-allocated type for holding nsStringBuffer* in the HTML parser.
An innerHTML setter profile shows about 10% of the time being spent under nsHtml5HtmlAttributes::clear, mostly deleting nsStrings.
This commit is contained in:
parent
41758fcea8
commit
1be77e0f3f
34 changed files with 719 additions and 358 deletions
|
|
@ -32,7 +32,7 @@
|
|||
|
||||
#include "nsIAtom.h"
|
||||
#include "nsHtml5AtomTable.h"
|
||||
#include "nsString.h"
|
||||
#include "nsHtml5String.h"
|
||||
#include "nsIContent.h"
|
||||
#include "nsTraceRefcnt.h"
|
||||
#include "jArray.h"
|
||||
|
|
@ -113,7 +113,8 @@ nsHtml5Tokenizer::setInterner(nsHtml5AtomTable* interner)
|
|||
}
|
||||
|
||||
void
|
||||
nsHtml5Tokenizer::initLocation(nsString* newPublicId, nsString* newSystemId)
|
||||
nsHtml5Tokenizer::initLocation(nsHtml5String newPublicId,
|
||||
nsHtml5String newSystemId)
|
||||
{
|
||||
this->systemId = newSystemId;
|
||||
this->publicId = newPublicId;
|
||||
|
|
@ -222,10 +223,11 @@ nsHtml5Tokenizer::emitOrAppendCharRefBuf(int32_t returnState)
|
|||
}
|
||||
}
|
||||
|
||||
nsString*
|
||||
nsHtml5String
|
||||
nsHtml5Tokenizer::strBufToString()
|
||||
{
|
||||
nsString* str = nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen, tokenHandler);
|
||||
nsHtml5String str =
|
||||
nsHtml5Portability::newStringFromBuffer(strBuf, 0, strBufLen, tokenHandler);
|
||||
clearStrBufAfterUse();
|
||||
return str;
|
||||
}
|
||||
|
|
@ -350,7 +352,7 @@ void
|
|||
nsHtml5Tokenizer::addAttributeWithValue()
|
||||
{
|
||||
if (attributeName) {
|
||||
nsString* val = strBufToString();
|
||||
nsHtml5String val = strBufToString();
|
||||
if (mViewSource) {
|
||||
mViewSource->MaybeLinkifyAttributeValue(attributeName, val);
|
||||
}
|
||||
|
|
@ -3496,11 +3498,11 @@ nsHtml5Tokenizer::initDoctypeFields()
|
|||
clearStrBufAfterUse();
|
||||
doctypeName = nsHtml5Atoms::emptystring;
|
||||
if (systemIdentifier) {
|
||||
nsHtml5Portability::releaseString(systemIdentifier);
|
||||
systemIdentifier.Release();
|
||||
systemIdentifier = nullptr;
|
||||
}
|
||||
if (publicIdentifier) {
|
||||
nsHtml5Portability::releaseString(publicIdentifier);
|
||||
publicIdentifier.Release();
|
||||
publicIdentifier = nullptr;
|
||||
}
|
||||
forceQuirks = false;
|
||||
|
|
@ -3662,11 +3664,11 @@ nsHtml5Tokenizer::eof()
|
|||
errEofInDoctype();
|
||||
doctypeName = nsHtml5Atoms::emptystring;
|
||||
if (systemIdentifier) {
|
||||
nsHtml5Portability::releaseString(systemIdentifier);
|
||||
systemIdentifier.Release();
|
||||
systemIdentifier = nullptr;
|
||||
}
|
||||
if (publicIdentifier) {
|
||||
nsHtml5Portability::releaseString(publicIdentifier);
|
||||
publicIdentifier.Release();
|
||||
publicIdentifier = nullptr;
|
||||
}
|
||||
forceQuirks = true;
|
||||
|
|
@ -3896,14 +3898,14 @@ nsHtml5Tokenizer::emitDoctypeToken(int32_t pos)
|
|||
cstart = pos + 1;
|
||||
tokenHandler->doctype(doctypeName, publicIdentifier, systemIdentifier, forceQuirks);
|
||||
doctypeName = nullptr;
|
||||
nsHtml5Portability::releaseString(publicIdentifier);
|
||||
publicIdentifier.Release();
|
||||
publicIdentifier = nullptr;
|
||||
nsHtml5Portability::releaseString(systemIdentifier);
|
||||
systemIdentifier.Release();
|
||||
systemIdentifier = nullptr;
|
||||
}
|
||||
|
||||
bool
|
||||
nsHtml5Tokenizer::internalEncodingDeclaration(nsString* internalCharset)
|
||||
nsHtml5Tokenizer::internalEncodingDeclaration(nsHtml5String internalCharset)
|
||||
{
|
||||
if (encodingDeclarationHandler) {
|
||||
return encodingDeclarationHandler->internalEncodingDeclaration(internalCharset);
|
||||
|
|
@ -3938,11 +3940,11 @@ nsHtml5Tokenizer::end()
|
|||
strBuf = nullptr;
|
||||
doctypeName = nullptr;
|
||||
if (systemIdentifier) {
|
||||
nsHtml5Portability::releaseString(systemIdentifier);
|
||||
systemIdentifier.Release();
|
||||
systemIdentifier = nullptr;
|
||||
}
|
||||
if (publicIdentifier) {
|
||||
nsHtml5Portability::releaseString(publicIdentifier);
|
||||
publicIdentifier.Release();
|
||||
publicIdentifier = nullptr;
|
||||
}
|
||||
if (tagName) {
|
||||
|
|
@ -4041,13 +4043,13 @@ nsHtml5Tokenizer::loadState(nsHtml5Tokenizer* other)
|
|||
} else {
|
||||
doctypeName = nsHtml5Portability::newLocalFromLocal(other->doctypeName, interner);
|
||||
}
|
||||
nsHtml5Portability::releaseString(systemIdentifier);
|
||||
systemIdentifier.Release();
|
||||
if (!other->systemIdentifier) {
|
||||
systemIdentifier = nullptr;
|
||||
} else {
|
||||
systemIdentifier = nsHtml5Portability::newStringFromString(other->systemIdentifier);
|
||||
}
|
||||
nsHtml5Portability::releaseString(publicIdentifier);
|
||||
publicIdentifier.Release();
|
||||
if (!other->publicIdentifier) {
|
||||
publicIdentifier = nullptr;
|
||||
} else {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue