Skip to content

Commit 55634b7

Browse files
committed
Implement in terms of public C API methods
1 parent bb9d829 commit 55634b7

File tree

3 files changed

+6
-4
lines changed

3 files changed

+6
-4
lines changed

lib/cext/ABI_check.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1 +1 @@
1-
12
1+
13

src/main/c/cext/string.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -160,7 +160,7 @@ VALUE rb_str_to_str(VALUE string) {
160160
}
161161

162162
VALUE rb_fstring(VALUE str) {
163-
return RUBY_INVOKE(str, "-@");
163+
return rb_str_to_interned_str(str);
164164
}
165165

166166
VALUE rb_str_buf_new(long capacity) {
@@ -440,9 +440,9 @@ long rb_str_coderange_scan_restartable(const char *s, const char *e, rb_encoding
440440

441441
VALUE rb_enc_interned_str_cstr(const char *ptr, rb_encoding *enc) {
442442
VALUE str = rb_enc_str_new_cstr(ptr, enc);
443-
return rb_fstring(str);
443+
return rb_str_to_interned_str(str);
444444
}
445445

446446
VALUE rb_str_to_interned_str(VALUE str) {
447-
return rb_fstring(str);
447+
return RUBY_INVOKE(str, "-@");
448448
}

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

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -796,6 +796,8 @@ RubyString rbStrNewNul(int byteLength,
796796

797797
}
798798

799+
/** Alternative to rb_str_new*() which does not copy the bytes from native memory, to use when the copy is
800+
* unnecessary. */
799801
@CoreMethod(names = "rb_tr_temporary_native_string", onSingleton = true, required = 3, lowerFixnum = 2)
800802
public abstract static class TemporaryNativeStringNode extends CoreMethodArrayArgumentsNode {
801803

0 commit comments

Comments
 (0)