ref: 82e650b577a5c7eea32fcff32d85b3fbcdfc6f0a
parent: b4d8077f0ce99505f7b65a67fc92aa20dc96ed78
author: rodri <rgl@antares-labs.eu>
date: Mon Dec 11 18:56:00 EST 2023
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.
--- a/obj.c
+++ b/obj.c
@@ -87,15 +87,12 @@
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 *
--- a/obj.h
+++ b/obj.h
@@ -80,6 +80,7 @@
{
char *name;
OBJElem *child;
+ OBJElem *lastone;
OBJObject *next;
};