зеркало из https://github.com/github/ruby.git
Make object ID faster by checking flags
We can improve object ID performance by checking the FL_SEEN_OBJ_ID flag instead of looking up in the table.
This commit is contained in:
Родитель
b51e1c07d8
Коммит
3f6be01bfc
|
@ -1683,13 +1683,17 @@ rb_gc_impl_object_id(void *objspace_ptr, VALUE obj)
|
|||
rb_objspace_t *objspace = objspace_ptr;
|
||||
|
||||
unsigned int lev = rb_gc_vm_lock();
|
||||
if (FL_TEST(obj, FL_SEEN_OBJ_ID)) {
|
||||
st_data_t val;
|
||||
if (st_lookup(objspace->obj_to_id_tbl, (st_data_t)obj, &val)) {
|
||||
GC_ASSERT(FL_TEST(obj, FL_SEEN_OBJ_ID));
|
||||
id = (VALUE)val;
|
||||
}
|
||||
else {
|
||||
GC_ASSERT(!FL_TEST(obj, FL_SEEN_OBJ_ID));
|
||||
rb_bug("rb_gc_impl_object_id: FL_SEEN_OBJ_ID flag set but not found in table");
|
||||
}
|
||||
}
|
||||
else {
|
||||
GC_ASSERT(!st_lookup(objspace->obj_to_id_tbl, (st_data_t)obj, NULL));
|
||||
|
||||
id = ULL2NUM(objspace->next_object_id);
|
||||
objspace->next_object_id += OBJ_ID_INCREMENT;
|
||||
|
|
Загрузка…
Ссылка в новой задаче