Skip to content

Commit 8822fa1

Browse files
committed
The padding is always positive, remove dead code
1 parent b2b2103 commit 8822fa1

File tree

2 files changed

+6
-15
lines changed

2 files changed

+6
-15
lines changed

src/main/java/org/truffleruby/core/time/RubyDateFormatter.java

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -614,7 +614,7 @@ public static boolean formatCanBeFast(Token[] compiledPattern) {
614614

615615
@ExplodeLoop
616616
public static Rope formatToRopeFast(Token[] compiledPattern, ZonedDateTime dt,
617-
RopeNodes.ConcatNode concatNode, RopeNodes.SubstringNode substringNode) {
617+
RopeNodes.ConcatNode concatNode) {
618618
Rope rope = null;
619619

620620
for (Token token : compiledPattern) {
@@ -661,6 +661,7 @@ public static Rope formatToRopeFast(Token[] compiledPattern, ZonedDateTime dt,
661661
// This fast-path only handles the '%6N' format, so output will always be 6 characters long.
662662
final int length = 6;
663663
final int padding = length - microSecondRope.characterLength();
664+
assert padding >= 0;
664665

665666
// `padding` is guaranteed to be >= 0 because `nano` can be at most 9 digits long before the
666667
// conversion to microseconds. The division further constrains the rope to be at most 6 digits long.

src/main/java/org/truffleruby/core/time/TimeNodes.java

Lines changed: 4 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -423,14 +423,9 @@ protected RubyString timeStrftime(RubyTime time, Object format,
423423
@Cached RopeNodes.EqualNode equalNode,
424424
@Cached("formatCanBeFast(pattern)") boolean canUseFast,
425425
@Cached ConditionProfile yearIsFastProfile,
426-
@Cached RopeNodes.ConcatNode concatNode,
427-
@Cached RopeNodes.SubstringNode substringNode) {
426+
@Cached RopeNodes.ConcatNode concatNode) {
428427
if (canUseFast && yearIsFastProfile.profile(yearIsFast(time))) {
429-
return makeStringNode.fromRope(RubyDateFormatter.formatToRopeFast(
430-
pattern,
431-
time.dateTime,
432-
concatNode,
433-
substringNode));
428+
return makeStringNode.fromRope(RubyDateFormatter.formatToRopeFast(pattern, time.dateTime, concatNode));
434429
} else {
435430
return makeStringNode.fromBuilderUnsafe(formatTime(time, pattern), CodeRange.CR_UNKNOWN);
436431
}
@@ -440,15 +435,10 @@ protected RubyString timeStrftime(RubyTime time, Object format,
440435
@Specialization(guards = "libFormat.isRubyString(format)")
441436
protected RubyString timeStrftime(RubyTime time, Object format,
442437
@CachedLibrary(limit = "2") RubyStringLibrary libFormat,
443-
@Cached RopeNodes.ConcatNode concatNode,
444-
@Cached RopeNodes.SubstringNode substringNode) {
438+
@Cached RopeNodes.ConcatNode concatNode) {
445439
final Token[] pattern = compilePattern(libFormat.getRope(format));
446440
if (formatCanBeFast(pattern) && yearIsFast(time)) {
447-
return makeStringNode.fromRope(RubyDateFormatter.formatToRopeFast(
448-
pattern,
449-
time.dateTime,
450-
concatNode,
451-
substringNode));
441+
return makeStringNode.fromRope(RubyDateFormatter.formatToRopeFast(pattern, time.dateTime, concatNode));
452442
} else {
453443
return makeStringNode.fromBuilderUnsafe(formatTime(time, pattern), CodeRange.CR_UNKNOWN);
454444
}

0 commit comments

Comments
 (0)