Skip to content

Commit

Permalink
refactor: unroll buffer initialization loop
Browse files Browse the repository at this point in the history
  • Loading branch information
lddubeau committed Aug 23, 2018
1 parent b8ec232 commit d0c8b37
Showing 1 changed file with 13 additions and 9 deletions.
22 changes: 13 additions & 9 deletions lib/saxes.js
Original file line number Diff line number Diff line change
Expand Up @@ -82,12 +82,6 @@ exports.EVENTS = [
"ready",
];

const buffers = [
"comment", "openWakaBang", "textNode", "tagName", "doctype", "piTarget",
"piBody", "entity", "attribName", "attribValue", "cdata", "xmlDeclName",
"xmlDeclValue",
];

const NL = 0xA;
const SPACE = 0x20;
const BANG = 0x21;
Expand Down Expand Up @@ -269,9 +263,19 @@ class SaxesParser {
* @private
*/
_init(opt) {
for (const buffer of buffers) {
this[buffer] = "";
}
this.comment = "";
this.openWakaBang = "";
this.textNode = "";
this.tagName = "";
this.doctype = "";
this.piTarget = "";
this.piBody = "";
this.entity = "";
this.attribName = "";
this.attribValue = "";
this.cdata = "";
this.xmlDeclName = "";
this.xmlDeclValue = "";

/**
* The options passed to the constructor of this parser.
Expand Down

0 comments on commit d0c8b37

Please sign in to comment.