summaryrefslogtreecommitdiff
path: root/string.c
diff options
context:
space:
mode:
authorJean Boussier <[email protected]>2025-06-13 11:23:32 +0200
committerJean Boussier <[email protected]>2025-06-13 19:46:29 +0200
commita99d941cacbb9d5d277400abf76f5648f91009ea (patch)
tree062e514cbaf393b275e5c111c7ace438bfed08be /string.c
parentfb0dbbc0e660d0c77ebba292578945aca8baafac (diff)
Add SHAPE_ID_HAS_IVAR_MASK for quick ivar check
This allow checking if an object has ivars with just a shape_id mask.
Notes
Notes: Merged: https://github.com/ruby/ruby/pull/13606
Diffstat (limited to 'string.c')
-rw-r--r--string.c9
1 files changed, 2 insertions, 7 deletions
diff --git a/string.c b/string.c
index 3ddd64ef25..6ab768c244 100644
--- a/string.c
+++ b/string.c
@@ -388,12 +388,7 @@ fstring_hash(VALUE str)
static inline bool
BARE_STRING_P(VALUE str)
{
- if (RBASIC_CLASS(str) != rb_cString) return false;
-
- if (FL_TEST_RAW(str, FL_EXIVAR)) {
- return rb_ivar_count(str) == 0;
- }
- return true;
+ return RBASIC_CLASS(str) == rb_cString && !rb_shape_obj_has_ivars(str);
}
static inline st_index_t
@@ -2316,7 +2311,7 @@ VALUE
rb_str_dup_m(VALUE str)
{
if (LIKELY(BARE_STRING_P(str))) {
- return str_duplicate(rb_obj_class(str), str);
+ return str_duplicate(rb_cString, str);
}
else {
return rb_obj_dup(str);