On Thu, Aug 29, 2024 at 03:15:02AM +0900, Masahiro Yamada wrote: > On Fri, Aug 16, 2024 at 2:39 AM Sami Tolvanen <samitolvanen@xxxxxxxxxx> wrote: > > +static int append_item(struct die *cd, struct die_fragment **res) > > +{ > > + struct die_fragment *prev; > > + struct die_fragment *df; > > + > > + df = malloc(sizeof(struct die_fragment)); > > + if (!df) { > > + error("malloc failed"); > > + return -1; > > + } > > + > > + df->type = EMPTY; > > + df->next = NULL; > > + > > + prev = cd->list; > > + while (prev && prev->next) > > + prev = prev->next; > > > > So, this entirely traverses the singly-linked list > every time a new item is appended to the tail. > > > In my analysis, this while loop iterates for thousands > of times in total for emitting each export symbol. > > > Why isn't this list_add_tail()? Good catch, I'll fix this in the next version. Keeping track of the last element should be sufficient, but I agree, using the existing list implementation is probably cleaner. Thanks! Sami