Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

slist_add() doing more than it needs to #17

Open
DFrostByte opened this issue Apr 4, 2015 · 1 comment
Open

slist_add() doing more than it needs to #17

DFrostByte opened this issue Apr 4, 2015 · 1 comment

Comments

@DFrostByte
Copy link
Contributor

In "list.c", slist_add() could be greatly simplified if we ignore the order - appending. This is how the code could look if we prepend to the list instead:

    void slist_add(formvars *item, formvars **list)
    {
        item->next = *list;
        *list = item;
    }
@LeSpocky
Copy link
Collaborator

Yes, this would speed up the insertion of new items, but I guess not much. The current code uses a pointer to the last element of the list. The test for *list or *start to be a NULL pointer can not be dropped, so you save only one assignment. The current code is basically this:

(*last)->next = item;
item->next = NULL;
*last = item;

Are you suffering from performance issues? I doubt this would be noticeable, not even with large numbers of additions, which we don't have in practice anyway?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants