|
65 | 65 | import org.truffleruby.RubyLanguage;
|
66 | 66 | import org.truffleruby.core.exception.ErrnoErrorNode;
|
67 | 67 | import org.truffleruby.core.rope.CodeRange;
|
68 |
| -import org.truffleruby.core.rope.ConcatRope; |
69 | 68 | import org.truffleruby.core.rope.LazyIntRope;
|
70 | 69 | import org.truffleruby.core.rope.LeafRope;
|
71 |
| -import org.truffleruby.core.rope.ManagedRope; |
72 | 70 | import org.truffleruby.core.rope.Rope;
|
73 | 71 | import org.truffleruby.core.rope.RopeBuilder;
|
74 | 72 | import org.truffleruby.core.rope.RopeConstants;
|
| 73 | +import org.truffleruby.core.rope.RopeNodes; |
75 | 74 | import org.truffleruby.core.rope.RopeOperations;
|
76 |
| -import org.truffleruby.core.rope.SubstringRope; |
77 | 75 | import org.truffleruby.core.string.RubyString;
|
78 | 76 | import org.truffleruby.core.string.StringOperations;
|
79 | 77 | import org.truffleruby.language.backtrace.Backtrace;
|
@@ -614,12 +612,12 @@ public static boolean formatToRopeBuilderCanBeFast(Token[] compiledPattern) {
|
614 | 612 | }
|
615 | 613 |
|
616 | 614 | @ExplodeLoop
|
617 |
| - public static ManagedRope formatToRopeBuilderFast(Token[] compiledPattern, ZonedDateTime dt, Object zone, |
618 |
| - RubyContext context, RubyLanguage language, Node currentNode, ErrnoErrorNode errnoErrorNode) { |
619 |
| - ManagedRope rope = null; |
| 615 | + public static Rope formatToRopeBuilderFast(Token[] compiledPattern, ZonedDateTime dt, |
| 616 | + RopeNodes.ConcatNode concatNode, RopeNodes.SubstringNode substringNode) { |
| 617 | + Rope rope = null; |
620 | 618 |
|
621 | 619 | for (Token token : compiledPattern) {
|
622 |
| - final ManagedRope appendRope; |
| 620 | + final Rope appendRope; |
623 | 621 |
|
624 | 622 | switch (token.getFormat()) {
|
625 | 623 | case FORMAT_ENCODING:
|
@@ -657,36 +655,30 @@ public static ManagedRope formatToRopeBuilderFast(Token[] compiledPattern, Zoned
|
657 | 655 |
|
658 | 656 | case FORMAT_NANOSEC: {
|
659 | 657 | final int nano = dt.getNano();
|
660 |
| - assert nano >= 0; |
661 |
| - assert nano < 1000000000; |
662 |
| - |
663 | 658 | final LazyIntRope nanoRope = new LazyIntRope(nano);
|
664 | 659 |
|
665 |
| - final int padding = 6 - nanoRope.characterLength(); |
| 660 | + final int length = 6; |
| 661 | + final int padding = length - nanoRope.characterLength(); |
666 | 662 |
|
667 | 663 | if (padding == 0) {
|
668 | 664 | appendRope = nanoRope;
|
669 | 665 | } else if (padding < 0) {
|
670 |
| - appendRope = new SubstringRope(UTF8Encoding.INSTANCE, nanoRope, 0, 6, 6, CodeRange.CR_7BIT); |
| 666 | + appendRope = substringNode.executeSubstring(nanoRope, 0, length); |
671 | 667 | } else {
|
672 |
| - appendRope = new ConcatRope( |
673 |
| - nanoRope, |
674 |
| - RopeConstants.paddingZeros(padding), |
675 |
| - UTF8Encoding.INSTANCE, |
676 |
| - CodeRange.CR_7BIT); |
| 668 | + appendRope = concatNode |
| 669 | + .executeConcat(nanoRope, RopeConstants.paddingZeros(padding), UTF8Encoding.INSTANCE); |
677 | 670 | }
|
678 | 671 | }
|
679 | 672 | break;
|
680 | 673 |
|
681 | 674 | default:
|
682 |
| - CompilerDirectives.shouldNotReachHere(); |
683 |
| - throw new UnsupportedOperationException(); |
| 675 | + throw CompilerDirectives.shouldNotReachHere(); |
684 | 676 | }
|
685 | 677 |
|
686 | 678 | if (rope == null) {
|
687 | 679 | rope = appendRope;
|
688 | 680 | } else {
|
689 |
| - rope = new ConcatRope(rope, appendRope, UTF8Encoding.INSTANCE, CodeRange.CR_UNKNOWN); |
| 681 | + rope = concatNode.executeConcat(rope, appendRope, UTF8Encoding.INSTANCE); |
690 | 682 | }
|
691 | 683 | }
|
692 | 684 |
|
|
0 commit comments