Feature #13381
[PATCH] Expose rb_fstring and its family to C extensions
Status:
Assigned
Priority:
Normal
Assignee:
-
Target version:
-
Description
https://github.com/ruby/ruby/pull/1559
Currently, C extensions cannot use fstrings. I'd like to use
rb_fstring_cstr
instead of rb_str_new_cstr
for static strings in C
extensions to avoid excess allocation.
I think there's several use cases.
- https://github.com/k0kubun/hamlit/blob/v2.8.0/ext/hamlit/hamlit.c#L508-L512
- https://bitbucket.org/ged/ruby-pg/src/e5eb92cca97abc0c6fc168acfad993c2ad314589/ext/pg_connection.c?at=v0.20.0&fileviewer=file-view-default#pg_connection.c-3679
- https://bitbucket.org/ged/ruby-pg/src/e5eb92cca97abc0c6fc168acfad993c2ad314589/ext/pg_copy_coder.c?at=v0.20.0&fileviewer=file-view-default#pg_copy_coder.c-38
History
Updated by ko1 (Koichi Sasada) over 2 years ago
- Status changed from Open to Feedback
I can understand use cases but we shouldn't expose the name "fstring".
Updated by eagletmt (Kohei Suzuki) over 2 years ago
OK, I've read comments of #13077.
What do you think of renaming fstring to "deduped" string? "Deduped" strings are implicitly frozen.
- Rename
rb_fstring
torb_str_deduped
- Rename
rb_fstring_new
torb_str_deduped_new
- Rename
rb_fstring_cstr
torb_str_deduped_cstr
- Rename
rb_fstring_enc_new
torb_enc_str_deduped_new
- Rename
rb_fstring_enc_cstr
torb_enc_str_deduped_cstr
- I think
enc
should come first for consistency
- I think
Updated by ko1 (Koichi Sasada) over 2 years ago
- Assignee set to ko1 (Koichi Sasada)
- Status changed from Feedback to Assigned
Updated by nobu (Nobuyoshi Nakada) over 2 years ago
- Assignee deleted (
ko1 (Koichi Sasada))
How about fixed_str
?