Skip to content

Commit 2986b0a

Browse files
committed
Fixed node count
1 parent ff1d89c commit 2986b0a

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

perf/perf.coffee

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -49,19 +49,20 @@ jsonNodeCount = (obj) ->
4949
for item in obj
5050
total += jsonNodeCount item
5151
else if _.isObject obj
52+
total += _.size obj
5253
for own key, val of obj
5354
total += jsonNodeCount val
5455
else
5556
total += 1
5657
return total
5758

5859
xmlNodeCount = (obj) ->
59-
total = 0
60+
total = 1
6061
if obj.attributes
6162
total += _.size obj.attributes
6263
if obj.instructions
6364
total += obj.instructions.length
64-
if obj.children and obj.children.length > 0
65+
if obj.children
6566
for item in obj.children
6667
total += xmlNodeCount item
6768
return total
@@ -107,7 +108,6 @@ doTest = (file, rep) ->
107108
if not nodeCount
108109
nodeCount = xmlNodeCount xml.root()
109110
console.log ' XML Node Count: ' + nodeCount
110-
console.log xml.root().children.length
111111
if not strSize
112112
strSize = Buffer.byteLength str, 'utf8'
113113
console.log ' XML String Size: ' + fmtSize(strSize)

0 commit comments

Comments
 (0)