diff options
author | Jemma Issroff <jemmaissroff@gmail.com> | 2022-01-25 16:04:17 -0500 |
---|---|---|
committer | Aaron Patterson <aaron.patterson@gmail.com> | 2022-01-26 09:02:59 -0800 |
commit | 1a180b7e18a2d415282df637e27a446c71246ef7 (patch) | |
tree | 5aee0a8491ba2736379924d87b6ecfbfa3892717 /vm_callinfo.h | |
parent | 3ce97a182f4310121e86dccf9fcd3ee3cb088107 (diff) |
Streamline cached attr reader / writer indexes
This commit removes the need to increment and decrement the indexes
used by vm_cc_attr_index getters and setters. It also introduces a
vm_cc_attr_index_p predicate function, and a vm_cc_attr_index_initalize
function.
Notes
Notes:
Merged: https://github.com/ruby/ruby/pull/5485
Diffstat (limited to 'vm_callinfo.h')
-rw-r--r-- | vm_callinfo.h | 19 |
1 files changed, 17 insertions, 2 deletions
diff --git a/vm_callinfo.h b/vm_callinfo.h index 09f755c818..3d41e039c9 100644 --- a/vm_callinfo.h +++ b/vm_callinfo.h @@ -353,7 +353,14 @@ static inline unsigned int vm_cc_attr_index(const struct rb_callcache *cc) { VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache)); - return cc->aux_.attr_index; + return cc->aux_.attr_index - 1; +} + +static inline bool +vm_cc_attr_index_p(const struct rb_callcache *cc) +{ + VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache)); + return cc->aux_.attr_index > 0; } static inline unsigned int @@ -406,7 +413,15 @@ vm_cc_attr_index_set(const struct rb_callcache *cc, int index) { VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache)); VM_ASSERT(cc != vm_cc_empty()); - *(int *)&cc->aux_.attr_index = index; + *(int *)&cc->aux_.attr_index = index + 1; +} + +static inline void +vm_cc_attr_index_initialize(const struct rb_callcache *cc) +{ + VM_ASSERT(IMEMO_TYPE_P(cc, imemo_callcache)); + VM_ASSERT(cc != vm_cc_empty()); + *(int *)&cc->aux_.attr_index = 0; } static inline void |