Skip to content

Commit 52a8583

Browse files
committed
Revert "improve performance of attributes reading"
This reverts commit e174168.
1 parent 8d187f9 commit 52a8583

1 file changed

Lines changed: 12 additions & 4 deletions

File tree

src/xmlparser/OrderedObjParser.js

Lines changed: 12 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -656,7 +656,7 @@ function isItStopNode() {
656656
*/
657657
function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
658658
let attrBoundary = 0;
659-
// const chars = [];
659+
const chars = [];
660660
const len = xmlData.length;
661661
const closeCode0 = closingChar.charCodeAt(0);
662662
const closeCode1 = closingChar.length > 1 ? closingChar.charCodeAt(1) : -1;
@@ -669,11 +669,19 @@ function tagExpWithClosingIndex(xmlData, i, closingChar = ">") {
669669
} else if (code === 34 || code === 39) { // " or '
670670
attrBoundary = code;
671671
} else if (code === closeCode0) {
672-
if (closeCode1 === -1 || xmlData.charCodeAt(index + 1) === closeCode1) {
673-
const data = xmlData.substring(i, index);
674-
return { data: data.replace(/\t/g, " "), index };
672+
if (closeCode1 !== -1) {
673+
if (xmlData.charCodeAt(index + 1) === closeCode1) {
674+
return { data: String.fromCharCode(...chars), index };
675+
}
676+
} else {
677+
return { data: String.fromCharCode(...chars), index };
675678
}
679+
} else if (code === 9) { // \t
680+
chars.push(32); // space
681+
continue;
676682
}
683+
684+
chars.push(code);
677685
}
678686
}
679687

0 commit comments

Comments
 (0)