@@ -172,6 +172,10 @@ def hex
172
172
Primitive . string_to_inum ( self , 16 , false , true )
173
173
end
174
174
175
+ def replace ( other )
176
+ Primitive . string_replace ( self , other )
177
+ end
178
+
175
179
def reverse
176
180
Primitive . dup_as_string_instance ( self ) . reverse!
177
181
end
@@ -392,7 +396,7 @@ def encode!(to=undefined, from=undefined, **options)
392
396
status = ec . primitive_convert src , dest , nil , nil
393
397
end
394
398
395
- return replace ( dest )
399
+ return Primitive . string_replace ( self , dest )
396
400
else
397
401
force_encoding to_enc
398
402
end
@@ -568,10 +572,10 @@ def inspect
568
572
569
573
def prepend ( *others )
570
574
if others . size == 1
571
- replace ( StringValue ( others . first ) + self )
575
+ Primitive . string_replace ( self , StringValue ( others . first ) + self )
572
576
else
573
577
reduced = others . reduce ( '' . encode ( self . encoding ) ) { |memo , other | memo + StringValue ( other ) }
574
- replace ( StringValue ( reduced ) + self )
578
+ Primitive . string_replace ( self , StringValue ( reduced ) + self )
575
579
end
576
580
end
577
581
@@ -622,7 +626,7 @@ def sub(pattern, replacement=undefined, &block)
622
626
matches = Truffle ::StringOperations . gsub_internal_matches ( false , self , pattern )
623
627
res = Truffle ::StringOperations . gsub_match_and_replace ( s , matches , replacement , &block )
624
628
Primitive . regexp_last_match_set ( Primitive . caller_special_variables , matches . last )
625
- s . replace ( res ) if res
629
+ Primitive . string_replace ( s , res ) if res
626
630
s
627
631
end
628
632
@@ -637,7 +641,7 @@ def sub!(pattern, replacement=undefined, &block)
637
641
res = Truffle ::StringOperations . gsub_match_and_replace ( self , matches , replacement , &block )
638
642
Primitive . regexp_last_match_set ( Primitive . caller_special_variables , matches . last )
639
643
if res
640
- replace ( res )
644
+ Primitive . string_replace ( self , res )
641
645
self
642
646
else
643
647
nil
@@ -867,7 +871,7 @@ def gsub(pattern, replacement=undefined, &block)
867
871
matches = Truffle ::StringOperations . gsub_internal_matches ( true , self , pattern )
868
872
res = Truffle ::StringOperations . gsub_match_and_replace ( s , matches , replacement , &block )
869
873
Primitive . regexp_last_match_set ( Primitive . caller_special_variables , matches . last )
870
- s . replace ( res ) if res
874
+ Primitive . string_replace ( s , res ) if res
871
875
s
872
876
end
873
877
@@ -882,7 +886,7 @@ def gsub!(pattern, replacement=undefined, &block)
882
886
res = Truffle ::StringOperations . gsub_match_and_replace ( self , matches , replacement , &block )
883
887
Primitive . regexp_last_match_set ( Primitive . caller_special_variables , matches . last )
884
888
if res
885
- replace ( res )
889
+ Primitive . string_replace ( self , res )
886
890
self
887
891
else
888
892
nil
@@ -946,7 +950,7 @@ def scrub(replace = nil, &block)
946
950
947
951
def scrub! ( replace = nil , &block )
948
952
return self if valid_encoding?
949
- replace ( scrub ( replace , &block ) )
953
+ Primitive . string_replace ( self , scrub ( replace , &block ) )
950
954
self
951
955
end
952
956
@@ -1151,13 +1155,13 @@ def insert(index, other)
1151
1155
Primitive . check_mutable_string self
1152
1156
1153
1157
if index == 0
1154
- replace ( other + self )
1158
+ Primitive . string_replace ( self , other + self )
1155
1159
elsif index == length
1156
1160
self << other
1157
1161
else
1158
1162
left = self [ 0 ...index ]
1159
1163
right = self [ index ..-1 ]
1160
- replace ( left + other + right )
1164
+ Primitive . string_replace ( self , left + other + right )
1161
1165
end
1162
1166
1163
1167
self
@@ -1297,7 +1301,7 @@ def unicode_normalize(form = :nfc)
1297
1301
end
1298
1302
1299
1303
def unicode_normalize! ( form = :nfc )
1300
- replace ( unicode_normalize ( form ) )
1304
+ Primitive . string_replace ( self , unicode_normalize ( form ) )
1301
1305
end
1302
1306
1303
1307
def unicode_normalized? ( form = :nfc )
0 commit comments