Skip to content
This repository was archived by the owner on Jan 7, 2021. It is now read-only.

Commit 44670f8

Browse files
committed
25% faster
1 parent e982acb commit 44670f8

1 file changed

Lines changed: 3 additions & 3 deletions

File tree

lib/xml2json.js

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -12,9 +12,9 @@ function startElement(name, attrs) {
1212
currentElementName = name;
1313
if(options.coerce) {
1414
// Looping here in stead of making coerce generic as object walk is unnecessary
15-
Object.keys(attrs).forEach(function(key) {
15+
for(key in attrs) {
1616
attrs[key] = coerce(attrs[key]);
17-
});
17+
}
1818
}
1919

2020
if (! (name in currentObject)) {
@@ -73,7 +73,7 @@ function endElement(name) {
7373
// matches the name we started on.
7474
var ancestor = ancestors.pop();
7575
if (!options.reversible) {
76-
if ((Object.keys(currentObject).length == 1) && ('$t' in currentObject)) {
76+
if (('$t' in currentObject) && (Object.keys(currentObject).length == 1)) {
7777
if (ancestor[name] instanceof Array) {
7878
ancestor[name].push(ancestor[name].pop()['$t']);
7979
} else {

0 commit comments

Comments
 (0)