summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorGravatar Nikias Bassen2018-12-10 02:20:24 +0100
committerGravatar Nikias Bassen2018-12-10 02:22:15 +0100
commit4de329327ce4aa175e8496d1bff8604bffb6c574 (patch)
tree0c5fce7e138756a2479acab5a3098fa12ea6971b /src
parent71dd25e14616bd261c3b6c80ff990cd1078266f6 (diff)
downloadlibplist-4de329327ce4aa175e8496d1bff8604bffb6c574.tar.gz
libplist-4de329327ce4aa175e8496d1bff8604bffb6c574.tar.bz2
Remove node_iterator and operate on node list directly to improve memory usage
Diffstat (limited to 'src')
-rw-r--r--src/bplist.c5
-rw-r--r--src/plist.c11
-rw-r--r--src/xplist.c5
3 files changed, 6 insertions, 15 deletions
diff --git a/src/bplist.c b/src/bplist.c
index 69f3dca..679a5e5 100644
--- a/src/bplist.c
+++ b/src/bplist.c
@@ -39,7 +39,6 @@
#include "ptrarray.h"
#include <node.h>
-#include <node_iterator.h>
/* Magic marker and size. */
#define BPLIST_MAGIC ((uint8_t*)"bplist")
@@ -938,12 +937,10 @@ static void serialize_plist(node_t* node, void* data)
ptr_array_add(ser->objects, node);
//now recurse on children
- node_iterator_t *ni = node_iterator_create(node->children);
node_t *ch;
- while ((ch = node_iterator_next(ni))) {
+ for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
serialize_plist(ch, data);
}
- node_iterator_destroy(ni);
return;
}
diff --git a/src/plist.c b/src/plist.c
index f62e6be..cd22ca6 100644
--- a/src/plist.c
+++ b/src/plist.c
@@ -36,7 +36,6 @@
#endif
#include <node.h>
-#include <node_iterator.h>
#include <hashtable.h>
extern void plist_xml_init(void);
@@ -209,12 +208,12 @@ static int plist_free_node(node_t* node)
plist_free_data(data);
node->data = NULL;
- node_iterator_t *ni = node_iterator_create(node->children);
node_t *ch;
- while ((ch = node_iterator_next(ni))) {
+ for (ch = node_first_child(node); ch; ) {
+ node_t *next = node_next_sibling(ch);
plist_free_node(ch);
+ ch = next;
}
- node_iterator_destroy(ni);
node_destroy(node);
@@ -366,12 +365,10 @@ static void plist_copy_node(node_t *node, void *parent_node_ptr)
*(plist_t*)parent_node_ptr = newnode;
}
- node_iterator_t *ni = node_iterator_create(node->children);
node_t *ch;
- while ((ch = node_iterator_next(ni))) {
+ for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
plist_copy_node(ch, &newnode);
}
- node_iterator_destroy(ni);
}
PLIST_API plist_t plist_copy(plist_t node)
diff --git a/src/xplist.c b/src/xplist.c
index 6e64427..29b1284 100644
--- a/src/xplist.c
+++ b/src/xplist.c
@@ -40,7 +40,6 @@
#include <node.h>
#include <node_list.h>
-#include <node_iterator.h>
#include "plist.h"
#include "base64.h"
@@ -356,12 +355,10 @@ static void node_to_xml(node_t* node, bytearray_t **outbuf, uint32_t depth)
if (node_data->type == PLIST_DICT) {
assert((node->children->count % 2) == 0);
}
- node_iterator_t *ni = node_iterator_create(node->children);
node_t *ch;
- while ((ch = node_iterator_next(ni))) {
+ for (ch = node_first_child(node); ch; ch = node_next_sibling(ch)) {
node_to_xml(ch, outbuf, depth+1);
}
- node_iterator_destroy(ni);
}
/* fix indent for structured types */