Initialize QualifiedName's strings from the read only data segment
authorbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jul 2012 01:05:23 +0000 (01:05 +0000)
committerbenjamin@webkit.org <benjamin@webkit.org@268f45cc-cd09-0410-ab3c-d52691b4dbfc>
Thu, 26 Jul 2012 01:05:23 +0000 (01:05 +0000)
commitf0ef0d91b3cdc4c957f45533427fac68bf4d07ee
tree0257fd5d852305bf78a963d35dcb79ea487b0e4e
parent7ec2278a6a3400d9e6559ec7b97058e4cbd8e302
Initialize QualifiedName's strings from the read only data segment
https://bugs.webkit.org/show_bug.cgi?id=92226

Patch by Benjamin Poulain <bpoulain@apple.com> on 2012-07-25
Reviewed by Anders Carlsson.

Source/WebCore:

Modify the initialization of static QualifiedName to initialize the AtomicString
with the data from the read only memory.

Overall, HTMLNames::init() gets 10% faster.

* dom/QualifiedName.cpp:
(WebCore::QualifiedName::QualifiedName):
* dom/QualifiedName.h:
(QualifiedName):
Remove the useless constructor taking a char* and get rid of the init() function.
The AtomicString representing the name should be constructed by the caller of QualifiedName.

Because the init() code is relatively large and is only executed once, it is important to
keep the AtomicString construction separate. The function createQualifiedName() was added
to improve the cache use. The short version let us reduce the code one more instruction per
call.

* dom/make_names.pl:
(printQualifiedNameMaker):
(printShortQualifiedNameMaker):
(printNamesCppFile):
(printDefinitions):

Source/WTF:

Add constructors for StringImpl and AtomicString to be able to create
the strings from the literal in read only memory.

* wtf/text/AtomicString.cpp:
(HashTranslatorCharBuffer):
(WTF::LCharBufferFromLiteralDataTranslator::hash):
(LCharBufferFromLiteralDataTranslator):
(WTF::LCharBufferFromLiteralDataTranslator::equal):
(WTF::LCharBufferFromLiteralDataTranslator::translate):
(WTF::AtomicString::addFromLiteralData):
* wtf/text/AtomicString.h:
(WTF::AtomicString::AtomicString):
(AtomicString):
* wtf/text/StringImpl.cpp:
(WTF::StringImpl::createFromLiteral):
* wtf/text/StringImpl.h:
(WTF):
(StringImpl):
(WTF::StringImpl::createFromLiteral):

git-svn-id: https://svn.webkit.org/repository/webkit/trunk@123689 268f45cc-cd09-0410-ab3c-d52691b4dbfc
Source/WTF/ChangeLog
Source/WTF/wtf/text/AtomicString.cpp
Source/WTF/wtf/text/AtomicString.h
Source/WTF/wtf/text/StringImpl.cpp
Source/WTF/wtf/text/StringImpl.h
Source/WebCore/ChangeLog
Source/WebCore/dom/QualifiedName.cpp
Source/WebCore/dom/QualifiedName.h
Source/WebCore/dom/make_names.pl