Skip to content

Commit c2b0154

Browse files
committed
Simplify some code.
1 parent 9826a6b commit c2b0154

File tree

2 files changed

+3
-8
lines changed

2 files changed

+3
-8
lines changed

src/main/java/org/truffleruby/core/rope/RopeNodes.java

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -365,10 +365,6 @@ public StringAttributes calculateAttributesGeneric(Encoding encoding, byte[] byt
365365
final int lengthOfCurrentCharacter = calculateCharacterLengthNode.characterLength(encoding, CR_UNKNOWN, bytes, p, end);
366366

367367
if (validCharacterProfile.profile(lengthOfCurrentCharacter > 0)) {
368-
if (codeRange != CR_BROKEN) {
369-
codeRange = CR_VALID;
370-
}
371-
372368
p += lengthOfCurrentCharacter;
373369
} else {
374370
codeRange = CR_BROKEN;
@@ -378,7 +374,7 @@ public StringAttributes calculateAttributesGeneric(Encoding encoding, byte[] byt
378374
if (fixedWidthProfile.profile(encoding.isFixedWidth())) {
379375
characters = (bytes.length + encoding.minLength() - 1) / encoding.minLength();
380376

381-
break;
377+
return new StringAttributes(characters, CR_BROKEN);
382378
} else {
383379
p++;
384380
}

src/main/ruby/core/string.rb

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -550,7 +550,7 @@ def inspect
550550
ascii = enc.ascii_compatible?
551551
unicode = Truffle.invoke_primitive :encoding_is_unicode, enc
552552

553-
actual_encoding = enc.dummy? ? Truffle.invoke_primitive(:get_actual_encoding, self) : enc
553+
actual_encoding = Truffle.invoke_primitive(:get_actual_encoding, self)
554554
if actual_encoding != enc
555555
enc = actual_encoding
556556
if unicode
@@ -636,8 +636,7 @@ def inspect_char(enc, result_encoding, ascii, unicode, index, char, array)
636636
end
637637
end
638638

639-
if (enc == result_encoding && Truffle.invoke_primitive(:character_printable_p, char)) ||
640-
(ascii && char.ascii_only? && Truffle.invoke_primitive(:character_printable_p, char))
639+
if Truffle.invoke_primitive(:character_printable_p, char) && (enc == result_encoding || (ascii && char.ascii_only?))
641640
array << char
642641
else
643642
code = char.ord

0 commit comments

Comments
 (0)