diff options
author | Yegappan Lakshmanan <yegappan@yahoo.com> | 2023-09-10 18:19:06 +0200 |
---|---|---|
committer | Christian Brabandt <cb@256bit.org> | 2023-09-10 18:19:06 +0200 |
commit | f36bbcd402c6ee5a27bcab3b20b6362ab93b8898 (patch) | |
tree | 1ab46f6dbc574548c8a9dea4ca6a661b36475899 /src/vim9execute.c | |
parent | 066103307534f81de08a092aac3a15e864a5a25f (diff) |
patch 9.0.1890: Vim9: lookup code for class/object repaeatedv9.0.1890
Problem: Vim9: lookup code for class/object repaeated
Solution: Refactor and make use of lookup functions
closes: #13067
Signed-off-by: Christian Brabandt <cb@256bit.org>
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/vim9execute.c')
-rw-r--r-- | src/vim9execute.c | 26 |
1 files changed, 10 insertions, 16 deletions
diff --git a/src/vim9execute.c b/src/vim9execute.c index 4a1dd1ce20..f8e2676410 100644 --- a/src/vim9execute.c +++ b/src/vim9execute.c @@ -2166,26 +2166,20 @@ execute_storeindex(isn_T *iptr, ectx_T *ectx) class_T *cl = obj->obj_class; char_u *member = tv_idx->vval.v_string; - ocmember_T *m = NULL; - for (int i = 0; i < cl->class_obj_member_count; ++i) + int m_idx; + ocmember_T *m = object_member_lookup(cl, member, 0, &m_idx); + if (m != NULL) { - m = &cl->class_obj_members[i]; - if (STRCMP(member, m->ocm_name) == 0) + if (*member == '_') { - if (*member == '_') - { - semsg(_(e_cannot_access_private_member_str), - m->ocm_name); - status = FAIL; - } - - lidx = i; - break; + semsg(_(e_cannot_access_private_member_str), + m->ocm_name); + status = FAIL; } - m = NULL; - } - if (m == NULL) + lidx = m_idx; + } + else { semsg(_(e_member_not_found_on_object_str_str), cl->class_name, member); |