diff options
author | Koichi Sasada <[email protected]> | 2021-11-18 11:01:31 +0900 |
---|---|---|
committer | Koichi Sasada <[email protected]> | 2021-11-19 08:32:39 +0900 |
commit | 82ea2870188d66aa75a99f03b4e7fdd1750aa196 (patch) | |
tree | 6ae732893312619a03e8dee23418a52df784d1f8 /vm_method.c | |
parent | be71c95b88019a1ca7a030a757ce343b743d8aff (diff) |
optimize `Struct` getter/setter
Introduce new optimized method type
`OPTIMIZED_METHOD_TYPE_STRUCT_AREF/ASET` with index information.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5131
Diffstat (limited to 'vm_method.c')
-rw-r--r-- | vm_method.c | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/vm_method.c b/vm_method.c index 1034332dde..d657d0612d 100644 --- a/vm_method.c +++ b/vm_method.c @@ -350,6 +350,7 @@ rb_add_method_optimized(VALUE klass, ID mid, enum method_optimized_type opt_type { rb_method_optimized_t opt = { .type = opt_type, + .index = index, }; rb_add_method(klass, mid, VM_METHOD_TYPE_OPTIMIZED, &opt, visi); } @@ -1940,7 +1941,8 @@ rb_method_definition_eq(const rb_method_definition_t *d1, const rb_method_defini case VM_METHOD_TYPE_UNDEF: return 1; case VM_METHOD_TYPE_OPTIMIZED: - return (d1->body.optimized.type == d2->body.optimized.type); + return (d1->body.optimized.type == d2->body.optimized.type) && + (d1->body.optimized.index == d2->body.optimized.index); case VM_METHOD_TYPE_REFINED: case VM_METHOD_TYPE_ALIAS: break; @@ -1974,6 +1976,7 @@ rb_hash_method_definition(st_index_t hash, const rb_method_definition_t *def) case VM_METHOD_TYPE_UNDEF: return hash; case VM_METHOD_TYPE_OPTIMIZED: + hash = rb_hash_uint(hash, def->body.optimized.index); return rb_hash_uint(hash, def->body.optimized.type); case VM_METHOD_TYPE_REFINED: case VM_METHOD_TYPE_ALIAS: |