Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse files

Fix compiler for new DNode logic

  • Loading branch information...
commit 17ea7681901ea6b0d069a3d1ebf1bcd9331ca43b 1 parent 0cef21e
@enebo enebo authored
View
7 src/org/jruby/ast/DNode.java
@@ -45,10 +45,11 @@ public boolean isSameEncoding(StrNode strNode) {
}
protected RubyString allocateString(Ruby runtime) {
- if (!is19()) return runtime.newString();
+ ByteList bytes = new ByteList();
- // FIXME: Need a nicer constructor...
- return RubyString.newStringNoCopy(runtime, new ByteList(), encoding, StringSupport.CR_7BIT);
+ if (is19()) bytes.setEncoding(encoding);
+
+ return RubyString.newStringShared(runtime, bytes, StringSupport.CR_7BIT);
}
public void appendToString(Ruby runtime, ThreadContext context, IRubyObject self, Block aBlock, RubyString string, Node node) {
View
17 src/org/jruby/compiler/impl/BaseBodyCompiler.java
@@ -450,19 +450,16 @@ public void createNewBignum(BigInteger value) {
public void createNewString(ArrayCallback callback, int count, Encoding encoding) {
loadRuntime();
-
- method.newobj(p(ByteList.class));
- method.dup();
- method.ldc(StandardASMCompiler.STARTING_DSTR_SIZE);
- method.invokespecial(p(ByteList.class), "<init>", sig(Void.TYPE, int.class));
+ ByteList startingDstr = new ByteList(StandardASMCompiler.STARTING_DSTR_SIZE);
if (encoding != null) {
- script.getCacheCompiler().cacheEncoding(this, encoding);
- method.ldc(StringSupport.CR_7BIT);
- method.invokestatic(p(RubyString.class), "newStringNoCopy", sig(RubyString.class, Ruby.class, ByteList.class, Encoding.class, int.class));
- } else {
- method.invokestatic(p(RubyString.class), "newStringLight", sig(RubyString.class, Ruby.class, ByteList.class));
+ startingDstr.setEncoding(encoding);
}
+
+ script.getCacheCompiler().cacheByteList(this, startingDstr);
+ method.invokevirtual(p(ByteList.class), "dup", sig(ByteList.class));
+ method.ldc(StringSupport.CR_7BIT);
+ method.invokestatic(p(RubyString.class), "newStringShared", sig(RubyString.class, Ruby.class, ByteList.class, int.class));
for (int i = 0; i < count; i++) {
callback.nextValue(this, null, i);
Please sign in to comment.
Something went wrong with that request. Please try again.