Skip to content

Commit

Permalink
json -ga performance degradation on long lines. Fixes #112.
Browse files Browse the repository at this point in the history
  • Loading branch information
twhiteman authored and trentm committed Mar 3, 2017
1 parent 9ea77c0 commit d504e2f
Show file tree
Hide file tree
Showing 3 changed files with 17 additions and 4 deletions.
11 changes: 10 additions & 1 deletion CHANGES.md
Original file line number Diff line number Diff line change
@@ -1,10 +1,19 @@
# json Changelog

## json 9.0.5 (not yet released)
## json 9.0.6 (not yet released)

(nothing yet)


## json 9.0.5

- [issue #112] Improve streaming (json -ga) performance for very long lines. For
example, using a 35 MB JSON object on one line gave a 50x speed improvement.
However, this is restricted to streaming of newline-separated JSON as opposed
to adjacent JSON objects not separated by newlines ({"a":1}{"a":2}). The
former case is expected to be much more common, and the latter may take a
slight performance hit from this change.

## json 9.0.4

- [issue #108] Fix a crash on `json foo.bar` if "foo" is null.
Expand Down
8 changes: 6 additions & 2 deletions lib/json.js
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
* See <https://github.com/trentm/json> and <https://trentm.com/json/>
*/

var VERSION = '9.0.5';
var VERSION = '9.0.6';

var p = console.warn;
var util = require('util');
Expand Down Expand Up @@ -627,7 +627,11 @@ function chunkEmitter(opts) {
chunks.push(chunk);
return;
}
leftover = emitChunks(s, emitter);
if (chunk.lastIndexOf('\n') >= 0) {
leftover = emitChunks(s, emitter);
} else {
leftover = s;
}
}
});
}
Expand Down
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
{
"name": "json",
"description": "a 'json' command for massaging and processing JSON on the command line",
"version": "9.0.5",
"version": "9.0.6",
"repository": {
"type": "git",
"url": "git://github.com/trentm/json.git"
Expand Down

0 comments on commit d504e2f

Please sign in to comment.