From fa04ab8e0c40cfc6b248c60e1ec9db028c97988a Mon Sep 17 00:00:00 2001 From: Tor Andersson Date: Wed, 22 Oct 2014 14:01:57 +0200 Subject: xml: Optimize creation of really long lists by keeping a tail pointer. --- source/fitz/xml.c | 8 ++++---- 1 file changed, 4 insertions(+), 4 deletions(-) (limited to 'source/fitz/xml.c') diff --git a/source/fitz/xml.c b/source/fitz/xml.c index a9d93eb8..5cdaa673 100644 --- a/source/fitz/xml.c +++ b/source/fitz/xml.c @@ -83,7 +83,7 @@ struct fz_xml_s char name[40]; char *text; struct attribute *atts; - fz_xml *up, *down, *prev, *next; + fz_xml *up, *down, *tail, *prev, *next; }; static inline void indent(int n) @@ -285,13 +285,13 @@ static void xml_emit_open_tag(struct parser *parser, char *a, char *b) if (!parser->head->down) { parser->head->down = head; + parser->head->tail = head; } else { - tail = parser->head->down; - while (tail->next) - tail = tail->next; + tail = parser->head->tail; tail->next = head; head->prev = tail; + parser->head->tail = head; } parser->head = head; -- cgit v1.2.3