diff options
author | Charles Oliver Nutter <headius@headius.com> | 2011-12-20 15:20:57 -0600 |
---|---|---|
committer | Charles Oliver Nutter <headius@headius.com> | 2011-12-20 22:19:27 -0600 |
commit | 52e55eaf3e7c28167e990310625645a3bb64467a (patch) | |
tree | d1d868f16d11f1caae315ba478993d77ec234a00 /java/src/json/ext/Parser.rl | |
parent | 6506aa32d5b7c56dc478cba2158e7ac7c2364be7 (diff) | |
download | json-52e55eaf3e7c28167e990310625645a3bb64467a.tar.gz |
Only allocate a single "view" bytelist, and update it as needed.
Conflicts:
java/src/json/ext/Parser.java
java/src/json/ext/Parser.rl
Diffstat (limited to 'java/src/json/ext/Parser.rl')
-rw-r--r-- | java/src/json/ext/Parser.rl | 11 |
1 files changed, 7 insertions, 4 deletions
diff --git a/java/src/json/ext/Parser.rl b/java/src/json/ext/Parser.rl index fd759f5..0dbc9c1 100644 --- a/java/src/json/ext/Parser.rl +++ b/java/src/json/ext/Parser.rl @@ -303,6 +303,7 @@ public class Parser extends RubyObject { private final Parser parser; private final ThreadContext context; private final ByteList byteList; + private final ByteList view; private final byte[] data; private final StringDecoder decoder; private int currentNesting = 0; @@ -317,6 +318,7 @@ public class Parser extends RubyObject { this.context = context; this.byteList = parser.checkAndGetSource().getByteList(); this.data = byteList.unsafeBytes(); + this.view = new ByteList(data, false); this.decoder = new StringDecoder(context); this.dc = new DoubleConverter(); } @@ -796,6 +798,7 @@ public class Parser extends RubyObject { %% write exec; if (cs < JSON_object_first_final) { + res.update(null, p + 1); return; } @@ -928,14 +931,14 @@ public class Parser extends RubyObject { } /** - * Returns a subsequence of the source ByteList, based on source - * array byte offsets (i.e., the ByteList's own begin offset is not - * automatically added). + * Updates the "view" bytelist with the new offsets and returns it. * @param start * @param end */ private ByteList absSubSequence(int absStart, int absEnd) { - return new ByteList(byteList.unsafeBytes(), absStart, absEnd - absStart, false); + view.setBegin(absStart); + view.setRealSize(absEnd - absStart); + return view; } /** |