Welcome to mirror list, hosted at ThFree Co, Russian Federation.

git.blender.org/blender.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCampbell Barton <ideasman42@gmail.com>2015-06-12 09:57:15 +0300
committerCampbell Barton <ideasman42@gmail.com>2015-06-12 10:13:34 +0300
commit4ab47a767067a88cfc82ae2e2214178b90e0f544 (patch)
tree6082569575478f91345a21a9b0b17878909fef7e /source/blender/blenlib/intern/storage.c
parent5893a3445e8227689c2f10b958a79f5f6ec18d20 (diff)
BLI_linklist, avoid full list search for append
For areas that require append, store the last node, Previous behavior would too easily hide poorly performing code. Also avoid (prepend, reverse) where possible.
Diffstat (limited to 'source/blender/blenlib/intern/storage.c')
-rw-r--r--source/blender/blenlib/intern/storage.c8
1 files changed, 3 insertions, 5 deletions
diff --git a/source/blender/blenlib/intern/storage.c b/source/blender/blenlib/intern/storage.c
index 6394187d40a..7b7733dea37 100644
--- a/source/blender/blenlib/intern/storage.c
+++ b/source/blender/blenlib/intern/storage.c
@@ -286,7 +286,7 @@ bool BLI_is_file(const char *path)
LinkNode *BLI_file_read_as_lines(const char *name)
{
FILE *fp = BLI_fopen(name, "r");
- LinkNode *lines = NULL;
+ LinkNodePair lines = {NULL, NULL};
char *buf;
size_t size;
@@ -315,7 +315,7 @@ LinkNode *BLI_file_read_as_lines(const char *name)
if (i == size || buf[i] == '\n') {
char *line = BLI_strdupn(&buf[last], i - last);
- BLI_linklist_prepend(&lines, line);
+ BLI_linklist_append(&lines, line);
/* faster to build singly-linked list in reverse order */
/* alternatively, could process buffer in reverse order so
* list ends up right way round to start with */
@@ -328,9 +328,7 @@ LinkNode *BLI_file_read_as_lines(const char *name)
fclose(fp);
- /* get them the right way round */
- BLI_linklist_reverse(&lines);
- return lines;
+ return lines.list;
}
/*