changed how to calculate the mid point in a binary search loop

This commit is contained in:
hyunghwan.chung 2017-05-04 05:22:45 +00:00
parent 68a7118fb2
commit 1dff630fdd
3 changed files with 19 additions and 5 deletions

View File

@ -8,6 +8,17 @@ class Exception(Apex)
{
var signalContext, handlerContext, messageText.
(*
TODO: can i convert 'thisProcess primError' to a relevant exception?
var(#class) primExceptTable.
method(#class) forPrimitiveError: no
{
^self.primExceptTable at: no
}
*)
method(#class) signal
{
^self new signal

View File

@ -804,13 +804,17 @@ int moo_genpfmethods (moo_t* moo, moo_mod_t* mod, moo_oop_class_t _class, const
moo_pfbase_t* moo_findpfbase (moo_t* moo, moo_pfinfo_t* pfinfo, moo_oow_t pfcount, const moo_ooch_t* name, moo_oow_t namelen)
{
int left, right, mid, n;
moo_oow_t left, right, mid;
int n;
/* binary search */
left = 0; right = pfcount - 1;
while (left <= right)
{
mid = (left + right) / 2;
/*mid = (left + right) / 2;*/
mid = left + ((right - left) / 2);
n = moo_compoocharsoocstr (name, namelen, pfinfo[mid].mthname);
if (n < 0) right = mid - 1;
@ -895,7 +899,6 @@ void* moo_getobjtrailer (moo_t* moo, moo_oop_t obj, moo_oow_t* size)
return MOO_OBJ_GET_TRAILER_BYTE(obj);
}
moo_oop_t moo_findclass (moo_t* moo, moo_oop_set_t nsdic, const moo_ooch_t* name)
{
moo_oop_association_t ass;

View File

@ -1281,8 +1281,8 @@ enum moo_synerrnum_t
MOO_SYNERR_CLASSDUPL, /* duplicate class */
MOO_SYNERR_CLASSCONTRA, /* contradictory class */
MOO_SYNERR_CLASSNAMEINVAL, /* wrong class name */
MOO_SYNERR_CLASSTRSIZE, /* non-pointer class inheriting a superclass with trailer size set */
MOO_SYNERR_CLASSFINAL, /* cannot inherit a #final class */
MOO_SYNERR_CLASSTRSIZE, /* non-pointer class now allowed to inherit a superclass with trailer size set */
MOO_SYNERR_CLASSFINAL, /* now allowed to inherit a #final class */
MOO_SYNERR_VARDCLBANNED, /* variable declaration not allowed */
MOO_SYNERR_MODIFIER, /* modifier expected */
MOO_SYNERR_MODIFIERINVAL, /* wrong modifier */