Add SHAPE_ID_HAS_IVAR_MASK for quick ivar check

This allow checking if an object has ivars with just a shape_id
mask.
This commit is contained in:
Jean Boussier 2025-06-13 11:23:32 +02:00
parent fb0dbbc0e6
commit a99d941cac
Notes: git 2025-06-13 17:46:42 +00:00
7 changed files with 41 additions and 13 deletions

View file

@ -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);