зеркало из https://github.com/github/ruby.git
Use FL_TEST_RAW in rb_hash_default_value
We should always have a T_HASH here, so we can use FL_TEST_RAW to avoid checking whether we may have an immediate value. I expect this to be a very small performance improvement (perf stat ./miniruby benchmark/hash_aref_miss.rb shows a ~1% improvement). It also removes 9 instructions from rb_hash_default_value on x86_64.
This commit is contained in:
Родитель
fbaa5db44a
Коммит
ea3d3c4552
4
hash.c
4
hash.c
|
@ -2088,9 +2088,11 @@ rb_hash_default_unredefined(VALUE hash)
|
|||
VALUE
|
||||
rb_hash_default_value(VALUE hash, VALUE key)
|
||||
{
|
||||
RUBY_ASSERT(RB_TYPE_P(hash, T_HASH));
|
||||
|
||||
if (LIKELY(rb_hash_default_unredefined(hash))) {
|
||||
VALUE ifnone = RHASH_IFNONE(hash);
|
||||
if (!FL_TEST(hash, RHASH_PROC_DEFAULT)) return ifnone;
|
||||
if (LIKELY(!FL_TEST_RAW(hash, RHASH_PROC_DEFAULT))) return ifnone;
|
||||
if (UNDEF_P(key)) return Qnil;
|
||||
return call_default_proc(ifnone, hash, key);
|
||||
}
|
||||
|
|
Загрузка…
Ссылка в новой задаче