Skip to content

Commit 4686aff

Browse files
dpalmeirohsivonen
authored andcommitted
Mozilla bug 1995614: Atomize ATTR_TYPE strings and any single digit strings during tokenization. r=hsivonen
Add static atoms for "2" -> "9", and do a fast path check for any single digit strings during tokenization and return the static atom directly. Also atomize type attributes during tokenization. This patch also cleans up some code in Element::SetAttr and nsHtml5TreeOperation so that it's easier to pass through an atom. Differential Revision: https://phabricator.services.mozilla.com/D269859
1 parent a96e7d8 commit 4686aff

File tree

1 file changed

+14
-1
lines changed

1 file changed

+14
-1
lines changed

src/nu/validator/htmlparser/impl/Tokenizer.java

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -998,8 +998,21 @@ private void emitOrAppendCharRefBuf(int returnState) throws SAXException {
998998
* @return the buffer as a string
999999
*/
10001000
@Inline protected String strBufToString() {
1001+
// CPPONLY: String digitAtom = TryAtomizeForSingleDigit();
1002+
// CPPONLY: if (digitAtom) {
1003+
// CPPONLY: return digitAtom;
1004+
// CPPONLY: }
1005+
// CPPONLY:
1006+
// CPPONLY: boolean maybeAtomize = false;
1007+
// CPPONLY: if (!newAttributesEachTime) {
1008+
// CPPONLY: if (attributeName == AttributeName.CLASS ||
1009+
// CPPONLY: attributeName == AttributeName.TYPE) {
1010+
// CPPONLY: maybeAtomize = true;
1011+
// CPPONLY: }
1012+
// CPPONLY: }
1013+
// CPPONLY:
10011014
String str = Portability.newStringFromBuffer(strBuf, 0, strBufLen
1002-
// CPPONLY: , tokenHandler, !newAttributesEachTime && attributeName == AttributeName.CLASS
1015+
// CPPONLY: , tokenHandler, maybeAtomize
10031016
);
10041017
clearStrBufAfterUse();
10051018
return str;

0 commit comments

Comments
 (0)