commit 80d1888c8d0480e64e27b979cf09da85058a158b
parent 6cad680c42d642fd273427cad7482daaa5976479
Author: Remy Noulin <loader2x@gmail.com>
Date: Sun, 23 Dec 2018 10:46:06 +0100
remove extra tmp variable
README.md | 2 +-
package.yml | 2 +-
singleList.h | 9 ++++-----
singleListe.h | 9 ++++-----
4 files changed, 10 insertions(+), 12 deletions(-)
Diffstat:
4 files changed, 10 insertions(+), 12 deletions(-)
diff --git a/README.md b/README.md
@@ -1,7 +1,7 @@
# Sheepy
This is a sheepy package for [sheepy](https://github.com/RemyNoulin/sheepy) and using [libsheepy](https://github.com/RemyNoulin/libsheepy)
-# single linked list
+# Single linked list
This package has 3 single linked list versions storing the list nodes in segments to reduce the frequency of memory allocations.
diff --git a/package.yml b/package.yml
@@ -1,6 +1,6 @@
---
name: singleList
- version: 0.0.1
+ version: 0.0.2
description: "single linked lists"
bin: ./singleList.h
#cflags: -DA -ggdb -std=gnu11 -fPIC -pipe
diff --git a/singleList.h b/singleList.h
@@ -368,12 +368,11 @@
singleListNodeType(name) UNIQVAR(refNode) = referenceNode;\
singleListNodeType(name) UNIQVAR(nodeToInsert) = nodeToInsert;\
/* save previous node index */\
- var UNIQVAR(tmp) = UNIQVAR(refNode)->prev;\
- /* previous node in now nodeToInsert */\
- UNIQVAR(refNode)->prev = UNIQVAR(nodeToInsert);\
/* connect rest of the list to nodeToInsert */\
- UNIQVAR(nodeToInsert)->prev = UNIQVAR(tmp);\
- if (!UNIQVAR(tmp)) /* referenceNode was head node */ (name)->head = UNIQVAR(nodeToInsert);\
+ UNIQVAR(nodeToInsert)->prev = UNIQVAR(refNode)->prev;\
+ /* previous node in now nodeToInsert */\
+ UNIQVAR(refNode)->prev = UNIQVAR(nodeToInsert);\
+ if (!UNIQVAR(nodeToInsert)->prev) /* referenceNode was head node */ (name)->head = UNIQVAR(nodeToInsert);\
(name)->count++;\
} while(0)
diff --git a/singleListe.h b/singleListe.h
@@ -423,12 +423,11 @@
singleListeNodeType(name) UNIQVAR(refNode) = referenceNode;\
singleListeNodeType(name) UNIQVAR(nodeToInsert) = nodeToInsert;\
/* save previous node index */\
- var UNIQVAR(tmp) = UNIQVAR(refNode)->prev;\
- /* previous node in now nodeToInsert */\
- UNIQVAR(refNode)->prev = UNIQVAR(nodeToInsert);\
/* connect rest of the list to nodeToInsert */\
- UNIQVAR(nodeToInsert)->prev = UNIQVAR(tmp);\
- if (!UNIQVAR(tmp)) /* referenceNode was head node */ (name)->head = UNIQVAR(nodeToInsert);\
+ UNIQVAR(nodeToInsert)->prev = UNIQVAR(refNode)->prev;\
+ /* previous node in now nodeToInsert */\
+ UNIQVAR(refNode)->prev = UNIQVAR(nodeToInsert);\
+ if (!UNIQVAR(nodeToInsert)->prev) /* referenceNode was head node */ (name)->head = UNIQVAR(nodeToInsert);\
(name)->count++;\
} while(0)