Skip to content

Commit 81d6904

Browse files
committed
Move setRope to RubyString
1 parent f6bd129 commit 81d6904

File tree

6 files changed

+51
-65
lines changed

6 files changed

+51
-65
lines changed

src/main/java/org/truffleruby/cext/CExtNodes.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -501,7 +501,7 @@ protected RubyString clearCodeRange(RubyString string,
501501
@Cached StringToNativeNode stringToNativeNode) {
502502
final NativeRope nativeRope = stringToNativeNode.executeToNative(string);
503503
nativeRope.clearCodeRange();
504-
StringOperations.setRope(string, nativeRope);
504+
string.setRope(nativeRope);
505505

506506
return string;
507507
}
@@ -623,7 +623,7 @@ protected RubyString strSetLen(RubyString string, int newByteLength,
623623
}
624624

625625
final NativeRope newNativeRope = nativeRope.withByteLength(newByteLength, newCharacterLength, newCodeRange);
626-
StringOperations.setRope(string, newNativeRope);
626+
string.setRope(newNativeRope);
627627

628628
return string;
629629
}
@@ -648,7 +648,7 @@ protected RubyString rbStrResize(RubyString string, int newByteLength,
648648
// Like MRI's rb_str_resize()
649649
newRope.clearCodeRange();
650650

651-
StringOperations.setRope(string, newRope);
651+
string.setRope(newRope);
652652
return string;
653653
}
654654
}
@@ -1001,7 +1001,7 @@ protected NativeRope toNative(RubyString string,
10011001
currentRope.getEncoding(),
10021002
characterLengthNode.execute(currentRope),
10031003
codeRangeNode.execute(currentRope));
1004-
StringOperations.setRope(string, nativeRope);
1004+
string.setRope(nativeRope);
10051005
}
10061006

10071007
return nativeRope;
@@ -1102,7 +1102,7 @@ protected int write(RubyString string, int index, int value,
11021102

11031103
final Rope newRope = setByteNode.executeSetByte(rope, index, value);
11041104
if (newRopeProfile.profile(newRope != rope)) {
1105-
StringOperations.setRope(string, newRope);
1105+
string.setRope(newRope);
11061106
}
11071107

11081108
return value;

src/main/java/org/truffleruby/core/encoding/EncodingConverterNodes.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -46,7 +46,6 @@
4646
import org.truffleruby.core.string.EncodingUtils;
4747
import org.truffleruby.core.string.RubyString;
4848
import org.truffleruby.core.string.StringNodes;
49-
import org.truffleruby.core.string.StringOperations;
5049
import org.truffleruby.core.string.StringUtils;
5150
import org.truffleruby.core.symbol.RubySymbol;
5251
import org.truffleruby.language.Nil;
@@ -314,7 +313,7 @@ private Object primitiveConvertHelper(RubyEncodingConverter encodingConverter, O
314313

315314
if (nonNullSource) {
316315
sourceRope = substringNode.executeSubstring(sourceRope, inPtr.p, sourceRope.byteLength() - inPtr.p);
317-
StringOperations.setRope((RubyString) source, sourceRope);
316+
((RubyString) source).setRope(sourceRope);
318317
}
319318

320319
if (growOutputBuffer && res == EConvResult.DestinationBufferFull) {
@@ -331,7 +330,7 @@ private Object primitiveConvertHelper(RubyEncodingConverter encodingConverter, O
331330
outBytes.setEncoding(ec.destinationEncoding);
332331
}
333332

334-
StringOperations.setRope(target, RopeOperations.ropeFromRopeBuilder(outBytes));
333+
target.setRope(RopeOperations.ropeFromRopeBuilder(outBytes));
335334

336335
return getSymbol(res.symbolicName());
337336
}

src/main/java/org/truffleruby/core/string/RubyString.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -46,6 +46,10 @@ public RubyString(RubyClass rubyClass, Shape shape, boolean frozen, boolean tain
4646
this.rope = rope;
4747
}
4848

49+
public void setRope(Rope rope) {
50+
this.rope = rope;
51+
}
52+
4953
/** should only be used for debugging */
5054
@Override
5155
public String toString() {

0 commit comments

Comments
 (0)