Skip to content

Commit c662354

Browse files
committed
Shorter path to encode strings in emitter
1 parent b8a09c1 commit c662354

File tree

1 file changed

+4
-1
lines changed

1 file changed

+4
-1
lines changed

ext/java/org/jruby/ext/psych/PsychEmitter.java

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,14 @@
3333
import org.jruby.RubyArray;
3434
import org.jruby.RubyBoolean;
3535
import org.jruby.RubyClass;
36+
import org.jruby.RubyEncoding;
3637
import org.jruby.RubyModule;
3738
import org.jruby.RubyObject;
3839
import org.jruby.RubyString;
3940
import org.jruby.anno.JRubyMethod;
4041
import org.jruby.runtime.ThreadContext;
4142
import org.jruby.runtime.builtin.IRubyObject;
43+
import org.jruby.util.ByteList;
4244
import org.jruby.util.IOOutputStream;
4345
import org.jruby.util.TypeConverter;
4446
import org.jruby.util.io.EncodingUtils;
@@ -375,8 +377,9 @@ private String exportToUTF8(ThreadContext context, IRubyObject tag, RubyClass st
375377

376378
TypeConverter.checkType(context, tag, stringClass);
377379
tagStr = (RubyString) tag;
380+
ByteList bytes = tagStr.getByteList();
378381

379-
return EncodingUtils.strConvEnc(context, tagStr, tagStr.getEncoding(), UTF8Encoding.INSTANCE).asJavaString();
382+
return RubyEncoding.decodeUTF8(bytes.unsafeBytes(), bytes.begin(), bytes.realSize());
380383
}
381384

382385
Emitter emitter;

0 commit comments

Comments
 (0)