diff options
author | Richard Braun <rbraun@sceen.net> | 2017-07-24 21:55:21 +0200 |
---|---|---|
committer | Richard Braun <rbraun@sceen.net> | 2017-07-24 21:55:21 +0200 |
commit | b4b0028d58aa76e3da39d9978975d672aa5fa809 (patch) | |
tree | 469e21c72908fd7effe2cc29e9169119c912fc7c /slist.h | |
parent | 3e5bd919e167c0d3ae4ca407fe3d88829d0261b5 (diff) |
slist: simplify slist_insert_after
Improve the efficiency of slist_insert_after by forbidding the prev pointer
to be NULL. This effectively delegates the check to the caller.
Diffstat (limited to 'slist.h')
-rw-r--r-- | slist.h | 14 |
1 files changed, 1 insertions, 13 deletions
@@ -189,19 +189,12 @@ slist_insert_tail(struct slist *list, struct slist_node *node) /* * Insert a node after another node. * - * The prev argument is used to determine the insertion point. It may safely - * denote the end of the given list, in which case the node is inserted at - * the head of the list. + * The prev node must be valid. */ static inline void slist_insert_after(struct slist *list, struct slist_node *prev, struct slist_node *node) { - if (slist_end(prev)) { - slist_insert_head(list, node); - return; - } - node->next = prev->next; prev->next = node; @@ -393,11 +386,6 @@ static inline void slist_llsync_insert_after(struct slist *list, struct slist_node *prev, struct slist_node *node) { - if (slist_end(prev)) { - slist_llsync_insert_head(list, node); - return; - } - node->next = prev->next; llsync_assign_ptr(prev->next, node); |