Index: TODO =================================================================== diff -u -re0f76d3c77189390606cd60012bff72e9bbb14a9 -rd9a6fbf56b9559455a3b57a31dcc76b388b2b1ab --- TODO (.../TODO) (revision e0f76d3c77189390606cd60012bff72e9bbb14a9) +++ TODO (.../TODO) (revision d9a6fbf56b9559455a3b57a31dcc76b388b2b1ab) @@ -2672,6 +2672,7 @@ * let result of "cls info heritage" return per-class mixins as well, otherwise it would be useless, since "cls info superclass -closure" would return the same + * replaced loops with NsfClassListFind() TODO: @@ -2688,8 +2689,6 @@ c) provide an additional flag to obtain mixins (not nice, since base version is useless) -- there are probably many more places, where NsfClassListFind() could be used. - - ::nsf::method::exists /handle/ -> check, if handle is a handle of a registered method (to be be used in serializer alias-dependency) - profiling missing when NSF_INVOKE_SHADOWED_TRADITIONAL is turned off. Index: generic/nsf.c =================================================================== diff -u -r5016c5d2fee323133f57ad401f1aa4f9d927cd2a -rd9a6fbf56b9559455a3b57a31dcc76b388b2b1ab --- generic/nsf.c (.../nsf.c) (revision 5016c5d2fee323133f57ad401f1aa4f9d927cd2a) +++ generic/nsf.c (.../nsf.c) (revision d9a6fbf56b9559455a3b57a31dcc76b388b2b1ab) @@ -5015,18 +5015,11 @@ if ((pl->cl->object.flags & NSF_IS_ROOT_CLASS) == 0) { NsfClassOpt *opt = pl->cl->opt; if (opt && opt->classmixins) { - /* compute transitively the (class) mixin classes of this - added class */ - NsfClasses *cls; - int i, found = 0; - for (i=0, cls = *checkList; cls; i++, cls = cls->nextPtr) { - /* fprintf(stderr, "+++ c%d: %s\n", i, ClassName(cls->cl));*/ - if (pl->cl == cls->cl) { - found = 1; - break; - } - } - if (!found) { + /* + * compute transitively the (class) mixin classes of this + * added class + */ + if (!NsfClassListFind(*checkList, pl->cl)) { NsfClassListAdd(checkList, pl->cl, NULL); /*fprintf(stderr, "+++ transitive %s\n", ObjStr(pl->cl->object.cmdName));*/ @@ -6863,10 +6856,7 @@ for (j = i+1; j < oc; j++) { NsfClasses *dl = ComputeOrder(scl[j], scl[j]->order, Super); if (reversed) break; - while (dl) { - if (dl->cl == scl[i]) break; - dl = dl->nextPtr; - } + dl = NsfClassListFind(dl, scl[i]); if (dl) reversed = 1; } } @@ -10290,7 +10280,7 @@ MEM_COUNT_ALLOC("Tcl_InitHashTable", slotTable); fullPrecendenceList = ComputePrecedenceList(interp, object, NULL /* pattern*/, 1, withRootClass); - for (pl=fullPrecendenceList; pl; pl = pl->nextPtr) { + for (pl = fullPrecendenceList; pl; pl = pl->nextPtr) { Tcl_DString ds, *dsPtr = &ds; DSTRING_INIT(dsPtr); @@ -12015,20 +12005,13 @@ static int IsSubType(NsfClass *subcl, NsfClass *cl) { - NsfClasses *t; - int success = 1; + assert(cl && subcl); if (cl != subcl) { - success = 0; - for (t = ComputeOrder(subcl, subcl->order, Super); t && t->cl; t = t->nextPtr) { - if (t->cl == cl) { - success = 1; - break; - } - } + return NsfClassListFind(ComputeOrder(subcl, subcl->order, Super), cl) != NULL; } - return success; + return 1; } static int @@ -18864,9 +18847,8 @@ */ static int NsfClassInfoHeritageMethod(Tcl_Interp *interp, NsfClass *cl, CONST char *pattern) { - NsfClasses *pl, *intrinsic; + NsfClasses *pl, *intrinsic, *checkList = NULL, *mixinClasses = NULL; int withMixins = 1; - NsfClasses *checkList = NULL, *mixinClasses = NULL; Tcl_ResetResult(interp);