Index: TODO =================================================================== diff -u -reea58c10308f2677f238bbc31c0276fbed7ce425 -r745cfb76b7b0dd189c8b6d71263dd066d4331a11 --- TODO (.../TODO) (revision eea58c10308f2677f238bbc31c0276fbed7ce425) +++ TODO (.../TODO) (revision 745cfb76b7b0dd189c8b6d71263dd066d4331a11) @@ -3717,6 +3717,10 @@ - update migration guide and tutorial - cleanup "//" in sources +nsf.c: +- adding method epoch incr to NsfAddObjectMethod() and NsfAddClassMethod() +- added function CmdListAddSorted() to improve mixinof management + ======================================================================== TODO: Index: generic/nsf.c =================================================================== diff -u -rf41102447b264605d111e97cab91f3c3ae717a66 -r745cfb76b7b0dd189c8b6d71263dd066d4331a11 --- generic/nsf.c (.../nsf.c) (revision f41102447b264605d111e97cab91f3c3ae717a66) +++ generic/nsf.c (.../nsf.c) (revision 745cfb76b7b0dd189c8b6d71263dd066d4331a11) @@ -4983,6 +4983,51 @@ return new; } +/* + *---------------------------------------------------------------------- + * CmdListAddSorted -- + * + * Add an entry to a cmdlist without duplicates. The order of the entries + * is not supposed to be relevant. This function maintains a sorted list to + * reduce cost to n/2. Can be improved be using better datastructures of + * needed. + * + * Results: + * The newly inserted command list item or a found item + * + * Side effects: + * Added List entry. + * + *---------------------------------------------------------------------- + */ +static NsfCmdList * +CmdListAddSorted(NsfCmdList **cList, Tcl_Command c, NsfClass *clorobj) { + NsfCmdList *prev, *new, *h; + + for (h = *cList, prev = NULL; h; prev = h, h = h->nextPtr) { + if (h->cmdPtr == c) { + return h; + } else if (h->cmdPtr > c) { + break; + } + } + + new = NEW(NsfCmdList); + new->cmdPtr = c; + NsfCommandPreserve(new->cmdPtr); + new->clientData = NULL; + new->clorobj = clorobj; + new->nextPtr = h; + + if (prev) { + prev->nextPtr = new; + } else { + *cList = new; + } + + return new; +} + static void CmdListReplaceCmd(NsfCmdList *replace, Tcl_Command cmd, NsfClass *clorobj) { Tcl_Command del = replace->cmdPtr; @@ -19548,7 +19593,8 @@ /* fprintf(stderr, "Registering object %s to isObjectMixinOf of class %s\n", ObjectName(object), ObjectName(nObject)); */ nclopt = NsfRequireClassOpt((NsfClass *)nObject); - CmdListAdd(&nclopt->isObjectMixinOf, object->id, NULL, /*noDuplicates*/ 1); + CmdListAddSorted(&nclopt->isObjectMixinOf, object->id, NULL); + } /* else fprintf(stderr, "Problem registering %s as a mixinof of %s\n", ObjStr(ov[i]), ClassName(cl)); */ } @@ -19606,7 +19652,7 @@ /* fprintf(stderr, "Registering class %s to isClassMixinOf of class %s\n", ClassName(cl), ObjectName(nObject)); */ nclopt = NsfRequireClassOpt((NsfClass *) nObject); - CmdListAdd(&nclopt->isClassMixinOf, cl->object.id, NULL, /*noDuplicates*/ 1); + CmdListAddSorted(&nclopt->isClassMixinOf, cl->object.id, NULL); } /* else fprintf(stderr, "Problem registering %s as a class-mixin of %s\n", ObjStr(ov[i]), ClassName(cl)); */ }