Skip to content

Commit

Permalink
perf: concatenate openWakaBang just once
Browse files Browse the repository at this point in the history
  • Loading branch information
lddubeau committed Aug 15, 2018
1 parent f270e8b commit 07345bf
Showing 1 changed file with 2 additions and 2 deletions.
4 changes: 2 additions & 2 deletions lib/saxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -734,7 +734,8 @@ class SaxesParser {
/** @private */
sOpenWakaBang(chunkState) {
const c = String.fromCodePoint(this.getCode(chunkState));
switch (this.openWakaBang + c) {
this.openWakaBang += c;
switch (this.openWakaBang) {
case "[CDATA[":
if (!this.sawRoot && !this.reportedTextBeforeRoot) {
this.fail("text data outside of root node.");
Expand Down Expand Up @@ -763,7 +764,6 @@ class SaxesParser {
this.openWakaBang = "";
break;
default:
this.openWakaBang += c;
// 7 happens to be the maximum length of the string that can possibly
// match one of the cases above.
if (this.openWakaBang.length >= 7) {
Expand Down

0 comments on commit 07345bf

Please sign in to comment.