diff options
author | Florian Frank <flori@ping.de> | 2011-01-03 02:22:49 +0100 |
---|---|---|
committer | Florian Frank <flori@ping.de> | 2011-01-03 02:22:49 +0100 |
commit | c87f6f3022f9b7c1b1317e958976e2ed6d4f4ae4 (patch) | |
tree | 7dc5bad2b78e9fa53aa667b88f1a5d6b461b909d /java/src/json/ext/Parser.rl | |
parent | 3b00ba0a9090f5f14b20e5debd4f7d6f421077ff (diff) | |
download | json-c87f6f3022f9b7c1b1317e958976e2ed6d4f4ae4.tar.gz |
avoid object creation
Diffstat (limited to 'java/src/json/ext/Parser.rl')
-rw-r--r-- | java/src/json/ext/Parser.rl | 12 |
1 files changed, 5 insertions, 7 deletions
diff --git a/java/src/json/ext/Parser.rl b/java/src/json/ext/Parser.rl index 642e56c..a79ead5 100644 --- a/java/src/json/ext/Parser.rl +++ b/java/src/json/ext/Parser.rl @@ -555,22 +555,20 @@ public class Parser extends RubyObject { if (parser.createAdditions) { RubyHash match = parser.match; if (match != null) { - final RubyArray memoArray = RubyArray.newArray(context.getRuntime(), 2); - memoArray.add(result); + final IRubyObject[] memoArray = { result, null }; try { match.visitAll(new RubyHash.Visitor() { @Override public void visit(IRubyObject pattern, IRubyObject klass) { - if (pattern.callMethod(context, "===", memoArray.entry(0)).isTrue()) { - memoArray.add(klass); + if (pattern.callMethod(context, "===", memoArray[0]).isTrue()) { + memoArray[1] = klass; throw JumpException.SPECIAL_JUMP; } } }); } catch (JumpException e) { } - IRubyObject matched = memoArray.entry(1); - if (!matched.isNil()) { - RubyClass klass = (RubyClass) matched; + if (memoArray[1] != null) { + RubyClass klass = (RubyClass) memoArray[1]; if (klass.respondsTo("json_creatable?") && klass.callMethod(context, "json_creatable?").isTrue()) { result = klass.callMethod(context, "json_create", result); |