summaryrefslogtreecommitdiff
path: root/vm_method.c
diff options
context:
space:
mode:
Diffstat (limited to 'vm_method.c')
-rw-r--r--vm_method.c12
1 files changed, 5 insertions, 7 deletions
diff --git a/vm_method.c b/vm_method.c
index 7546a1c31c..af7c99a95f 100644
--- a/vm_method.c
+++ b/vm_method.c
@@ -387,15 +387,13 @@ static rb_method_entry_t*
search_method(VALUE klass, ID id)
{
st_data_t body;
- if (!klass) {
- return 0;
- }
- while (!RCLASS_M_TBL(klass) || !st_lookup(RCLASS_M_TBL(klass), id, &body)) {
- klass = RCLASS_SUPER(klass);
- if (!klass) {
- return 0;
+ for (body = 0; klass; klass = RCLASS_SUPER(klass)) {
+ st_table *m_tbl = RCLASS_M_TBL(klass);
+ if (!m_tbl) {
+ m_tbl = RCLASS_M_TBL(RCLASS_ORIGIN(RBASIC(klass)->klass));
}
+ if (st_lookup(m_tbl, id, &body)) break;
}
return (rb_method_entry_t *)body;