mirror of
https://github.com/vim/vim.git
synced 2025-09-23 03:43:49 -04:00
patch 9.0.1837: Vim9: class_member_type() can be optimized
Problem: Vim9: class_member_type() can be optimized Solution: class_member_type() provides more information; safe an additional alloc()/free() closes: #12989 Signed-off-by: Christian Brabandt <cb@256bit.org> Co-authored-by: Ernie Rael <errael@raelity.com>
This commit is contained in:
committed by
Christian Brabandt
parent
c41b7a26fc
commit
456ae556b4
@@ -1866,27 +1866,21 @@ compile_lhs(
|
||||
{
|
||||
// for an object or class member get the type of the member
|
||||
class_T *cl = lhs->lhs_type->tt_class;
|
||||
omacc_T access;
|
||||
ocmember_T *m;
|
||||
|
||||
lhs->lhs_member_type = class_member_type(cl, after + 1,
|
||||
lhs->lhs_end, &lhs->lhs_member_idx,
|
||||
&access);
|
||||
lhs->lhs_end, &lhs->lhs_member_idx, &m);
|
||||
if (lhs->lhs_member_idx < 0)
|
||||
return FAIL;
|
||||
|
||||
// If it is private member variable, then accessing it outside the
|
||||
// class is not allowed.
|
||||
if ((access != VIM_ACCESS_ALL) && !inside_class(cctx, cl))
|
||||
if ((m->ocm_access != VIM_ACCESS_ALL) && !inside_class(cctx, cl))
|
||||
{
|
||||
char_u *m_name;
|
||||
char *msg;
|
||||
|
||||
m_name = vim_strnsave(after + 1, lhs->lhs_end - after - 1);
|
||||
msg = (access == VIM_ACCESS_PRIVATE)
|
||||
char *msg = (m->ocm_access == VIM_ACCESS_PRIVATE)
|
||||
? e_cannot_access_private_member_str
|
||||
: e_cannot_change_readonly_variable_str;
|
||||
semsg(_(msg), m_name);
|
||||
vim_free(m_name);
|
||||
semsg(_(msg), m->ocm_name);
|
||||
return FAIL;
|
||||
}
|
||||
}
|
||||
@@ -2097,10 +2091,9 @@ compile_load_lhs_with_index(lhs_T *lhs, char_u *var_start, cctx_T *cctx)
|
||||
return FAIL;
|
||||
|
||||
class_T *cl = lhs->lhs_type->tt_class;
|
||||
omacc_T access;
|
||||
type_T *type = class_member_type(cl, dot + 1,
|
||||
lhs->lhs_end, &lhs->lhs_member_idx,
|
||||
&access);
|
||||
NULL);
|
||||
if (lhs->lhs_member_idx < 0)
|
||||
return FAIL;
|
||||
|
||||
|
Reference in New Issue
Block a user