зеркало из https://github.com/github/ruby.git
Skip a redundant check for the rb_obj_hash case
Also, refactor the cfunc struct to use a new rb_cfunc_t.
This commit is contained in:
Родитель
5a3ae06a09
Коммит
61fbd29e14
6
hash.c
6
hash.c
|
@ -220,12 +220,12 @@ obj_any_hash(VALUE obj)
|
||||||
VALUE klass = CLASS_OF(obj);
|
VALUE klass = CLASS_OF(obj);
|
||||||
if (klass) {
|
if (klass) {
|
||||||
const rb_callable_method_entry_t *cme = rb_callable_method_entry(klass, id_hash);
|
const rb_callable_method_entry_t *cme = rb_callable_method_entry(klass, id_hash);
|
||||||
if (cme && METHOD_ENTRY_BASIC(cme) && RBASIC_CLASS(cme->defined_class) == rb_mKernel) {
|
if (cme && METHOD_ENTRY_BASIC(cme)) {
|
||||||
// Optimize away the frame push overhead if it's the default Kernel#hash
|
// Optimize away the frame push overhead if it's the default Kernel#hash
|
||||||
if (cme->def->type == VM_METHOD_TYPE_CFUNC && cme->def->body.cfunc.func == (VALUE (*)(ANYARGS))rb_obj_hash) {
|
if (cme->def->type == VM_METHOD_TYPE_CFUNC && cme->def->body.cfunc.func == (rb_cfunc_t)rb_obj_hash) {
|
||||||
hval = rb_obj_hash(obj);
|
hval = rb_obj_hash(obj);
|
||||||
}
|
}
|
||||||
else {
|
else if (RBASIC_CLASS(cme->defined_class) == rb_mKernel) {
|
||||||
hval = rb_vm_call0(GET_EC(), obj, id_hash, 0, 0, cme, 0);
|
hval = rb_vm_call0(GET_EC(), obj, id_hash, 0, 0, cme, 0);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
3
method.h
3
method.h
|
@ -136,8 +136,9 @@ typedef struct rb_method_iseq_struct {
|
||||||
rb_cref_t * cref; /*!< class reference, should be marked */
|
rb_cref_t * cref; /*!< class reference, should be marked */
|
||||||
} rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
|
} rb_method_iseq_t; /* check rb_add_method_iseq() when modify the fields */
|
||||||
|
|
||||||
|
typedef VALUE (*rb_cfunc_t)(ANYARGS);
|
||||||
typedef struct rb_method_cfunc_struct {
|
typedef struct rb_method_cfunc_struct {
|
||||||
VALUE (*func)(ANYARGS);
|
rb_cfunc_t func;
|
||||||
VALUE (*invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
|
VALUE (*invoker)(VALUE recv, int argc, const VALUE *argv, VALUE (*func)(ANYARGS));
|
||||||
int argc;
|
int argc;
|
||||||
} rb_method_cfunc_t;
|
} rb_method_cfunc_t;
|
||||||
|
|
Загрузка…
Ссылка в новой задаче