exposed moo_lookupdic_noseterr() which doesn't set error information upon failure so as to avoid setting error information unnecessarily during method lookup(moo_findmethod(), etc)
This commit is contained in:
parent
1d3d7aee4c
commit
8d10b4a5fa
@ -197,7 +197,7 @@ oops:
|
|||||||
return MOO_NULL;
|
return MOO_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
static moo_oop_association_t lookup (moo_t* moo, moo_oop_dic_t dic, const moo_oocs_t* name)
|
moo_oop_association_t moo_lookupdic_noseterr (moo_t* moo, moo_oop_dic_t dic, const moo_oocs_t* name)
|
||||||
{
|
{
|
||||||
/* this is special version of moo_getatsysdic() that performs
|
/* this is special version of moo_getatsysdic() that performs
|
||||||
* lookup using a plain string specified */
|
* lookup using a plain string specified */
|
||||||
@ -228,10 +228,22 @@ static moo_oop_association_t lookup (moo_t* moo, moo_oop_dic_t dic, const moo_oo
|
|||||||
}
|
}
|
||||||
|
|
||||||
/* when value is MOO_NULL, perform no insertion */
|
/* when value is MOO_NULL, perform no insertion */
|
||||||
moo_seterrbfmt (moo, MOO_ENOENT, "unable to find %.*js in a dictionary", name->len, name->ptr);
|
|
||||||
|
/* moo_seterrXXX() is not called here. the dictionary lookup is very frequent
|
||||||
|
* and so is lookup failure. for instance, moo_findmethod() calls this over
|
||||||
|
* a class chain. there might be a failure at each class level. it's waste to
|
||||||
|
* set the error information whenever the failure occurs.
|
||||||
|
* the caller of this function must set the error information upon failure */
|
||||||
return MOO_NULL;
|
return MOO_NULL;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static MOO_INLINE moo_oop_association_t lookup (moo_t* moo, moo_oop_dic_t dic, const moo_oocs_t* name)
|
||||||
|
{
|
||||||
|
moo_oop_association_t ass = moo_lookupdic_noseterr(moo, dic, name);
|
||||||
|
if (!ass) moo_seterrbfmt(moo, MOO_ENOENT, "unable to find %.*js in a dictionary", name->len, name->ptr);
|
||||||
|
return ass;
|
||||||
|
}
|
||||||
|
|
||||||
moo_oop_association_t moo_putatsysdic (moo_t* moo, moo_oop_t key, moo_oop_t value)
|
moo_oop_association_t moo_putatsysdic (moo_t* moo, moo_oop_t key, moo_oop_t value)
|
||||||
{
|
{
|
||||||
MOO_ASSERT (moo, MOO_CLASSOF(moo,key) == moo->_symbol);
|
MOO_ASSERT (moo, MOO_CLASSOF(moo,key) == moo->_symbol);
|
||||||
|
@ -1635,7 +1635,7 @@ static MOO_INLINE moo_oop_method_t find_method_in_class (moo_t* moo, moo_oop_cla
|
|||||||
MOO_ASSERT (moo, (moo_oop_t)mthdic != moo->_nil);
|
MOO_ASSERT (moo, (moo_oop_t)mthdic != moo->_nil);
|
||||||
MOO_ASSERT (moo, MOO_CLASSOF(moo, mthdic) == moo->_method_dictionary);
|
MOO_ASSERT (moo, MOO_CLASSOF(moo, mthdic) == moo->_method_dictionary);
|
||||||
|
|
||||||
ass = (moo_oop_association_t)moo_lookupdic(moo, mthdic, name);
|
ass = (moo_oop_association_t)moo_lookupdic_noseterr(moo, mthdic, name);
|
||||||
if (ass)
|
if (ass)
|
||||||
{
|
{
|
||||||
/* found the method */
|
/* found the method */
|
||||||
@ -1711,7 +1711,6 @@ moo_oop_method_t moo_findmethod (moo_t* moo, moo_oop_t receiver, const moo_oocs_
|
|||||||
* otherwise c points to a class object */
|
* otherwise c points to a class object */
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
/* [IMPORT] the method lookup logic should be the same as ciim_on_each_method() in comp.c */
|
/* [IMPORT] the method lookup logic should be the same as ciim_on_each_method() in comp.c */
|
||||||
mth = find_method_in_class_chain(moo, c, mth_type, message);
|
mth = find_method_in_class_chain(moo, c, mth_type, message);
|
||||||
if (mth) return mth;
|
if (mth) return mth;
|
||||||
|
@ -1173,6 +1173,12 @@ moo_oop_association_t moo_getatdic (
|
|||||||
moo_oop_t key
|
moo_oop_t key
|
||||||
);
|
);
|
||||||
|
|
||||||
|
moo_oop_association_t moo_lookupdic_noseterr (
|
||||||
|
moo_t* moo,
|
||||||
|
moo_oop_dic_t dic,
|
||||||
|
const moo_oocs_t* name
|
||||||
|
);
|
||||||
|
|
||||||
moo_oop_association_t moo_lookupdic (
|
moo_oop_association_t moo_lookupdic (
|
||||||
moo_t* moo,
|
moo_t* moo,
|
||||||
moo_oop_dic_t dic,
|
moo_oop_dic_t dic,
|
||||||
|
Loading…
Reference in New Issue
Block a user