mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
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:
parent
fb0dbbc0e6
commit
a99d941cac
Notes:
git
2025-06-13 17:46:42 +00:00
7 changed files with 41 additions and 13 deletions
9
string.c
9
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);
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue