diff options
author | rodri <rgl@antares-labs.eu> | 2023-12-11 23:56:00 +0000 |
---|---|---|
committer | rodri <rgl@antares-labs.eu> | 2023-12-11 23:56:00 +0000 |
commit | 82e650b577a5c7eea32fcff32d85b3fbcdfc6f0a (patch) | |
tree | c031000145289aa37cd36c88a79d558ea03ba7a0 | |
parent | b4d8077f0ce99505f7b65a67fc92aa20dc96ed78 (diff) | |
download | libobj-82e650b577a5c7eea32fcff32d85b3fbcdfc6f0a.tar.gz libobj-82e650b577a5c7eea32fcff32d85b3fbcdfc6f0a.tar.bz2 libobj-82e650b577a5c7eea32fcff32d85b3fbcdfc6f0a.zip |
improve element insertion procedure.
brought the processing time of a 38MB file from
26 minutes down to less than 20 seconds with
this change. it was a very naive insertion
procedure that was waiting to be pruned.
-rw-r--r-- | obj.c | 11 | ||||
-rw-r--r-- | obj.h | 1 |
2 files changed, 5 insertions, 7 deletions
@@ -87,15 +87,12 @@ addvert(OBJ *obj, OBJVertex v, int vtype) static void addelem(OBJObject *o, OBJElem *e) { - OBJElem *ep; - - if(o->child == nil){ - o->child = e; + if(o->lastone == nil){ + o->lastone = o->child = e; return; } - for(ep = o->child; ep->next != nil; ep = ep->next) - ; - ep->next = e; + o->lastone->next = e; + o->lastone = o->lastone->next; } static OBJElem * @@ -80,6 +80,7 @@ struct OBJObject { char *name; OBJElem *child; + OBJElem *lastone; OBJObject *next; }; |