summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--ext/java/org/jruby/ext/psych/PsychEmitter.java20
1 files changed, 9 insertions, 11 deletions
diff --git a/ext/java/org/jruby/ext/psych/PsychEmitter.java b/ext/java/org/jruby/ext/psych/PsychEmitter.java
index baaca4a..4df7989 100644
--- a/ext/java/org/jruby/ext/psych/PsychEmitter.java
+++ b/ext/java/org/jruby/ext/psych/PsychEmitter.java
@@ -118,17 +118,14 @@ public class PsychEmitter extends RubyObject {
initEmitter(context, encoding);
- StreamStartEvent event = new StreamStartEvent(NULL_MARK, NULL_MARK);
-
- emit(context, event);
+ emit(context, NULL_STREAM_START_EVENT);
return this;
}
@JRubyMethod
public IRubyObject end_stream(ThreadContext context) {
- StreamEndEvent event = new StreamEndEvent(NULL_MARK, NULL_MARK);
- emit(context, event);
+ emit(context, NULL_STREAM_START_EVENT);
return this;
}
@@ -368,16 +365,16 @@ public class PsychEmitter extends RubyObject {
return dumpSettingsBuilder.build();
}
- private String exportToUTF8(ThreadContext context, IRubyObject tag, RubyClass stringClass) {
- if (tag.isNil()) {
+ private String exportToUTF8(ThreadContext context, IRubyObject maybeString, RubyClass stringClass) {
+ if (maybeString.isNil()) {
return null;
}
- RubyString tagStr;
+ RubyString string;
- TypeConverter.checkType(context, tag, stringClass);
- tagStr = (RubyString) tag;
- ByteList bytes = tagStr.getByteList();
+ TypeConverter.checkType(context, maybeString, stringClass);
+ string = (RubyString) maybeString;
+ ByteList bytes = string.getByteList();
return RubyEncoding.decodeUTF8(bytes.unsafeBytes(), bytes.begin(), bytes.realSize());
}
@@ -388,6 +385,7 @@ public class PsychEmitter extends RubyObject {
IRubyObject io;
private static final Optional<Mark> NULL_MARK = Optional.empty();
+ private static final StreamStartEvent NULL_STREAM_START_EVENT = new StreamStartEvent(NULL_MARK, NULL_MARK);
// Map style constants from Psych values (ANY = 0 ... FOLDED = 5)
// to SnakeYaml values; see psych/nodes/scalar.rb.