From d0c8b37bc9276e3d3538d7885e29f49a393a3104 Mon Sep 17 00:00:00 2001 From: Louis-Dominique Dubeau <ldd@lddubeau.com> Date: Thu, 23 Aug 2018 18:42:56 -0400 Subject: [PATCH] refactor: unroll buffer initialization loop --- lib/saxes.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/lib/saxes.js b/lib/saxes.js index f181a7f6..83577e93 100644 --- a/lib/saxes.js +++ b/lib/saxes.js @@ -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; @@ -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.