The Birdfont Source Code


All Repositories / birdfont.git / commit – RSS feed

Faster xml parsing

These changes was commited to the Birdfont repository Mon, 25 May 2015 11:18:38 +0000.

Contributing

Send patches or pull requests to johan.mattsson.m@gmail.com.
Clone this repository: git clone https://github.com/johanmattssonm/birdfont.git
author Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 25 May 2015 11:18:38 +0000 (13:18 +0200)
committer Johan Mattsson <johan.mattsson.m@gmail.com>
Mon, 25 May 2015 11:18:38 +0000 (13:18 +0200)
commit 09bdb33481f43f87774dc5ace9fa1938470b9c57
tree e30e050c58db774ac039f6199209d4beb14f08ec
parent 0ae563fe07f5df2eef49d1b92c1552dc0adde6e1
Faster xml parsing

libbirdxml/Tag.vala
libbirdxml/XmlString.vala
--- a/libbirdxml/Tag.vala +++ b/libbirdxml/Tag.vala @@ -149,7 +149,8 @@ int end; int closing_tag; XmlString? d; - + char* start_tag_data; + XmlString name; XmlString attributes; XmlString content; @@ -169,6 +170,7 @@ return new Tag.empty (); } + index += data.find_char ('<'); while (data.get_next_char (ref index, out c)) { if (c == '<') { separator = find_next_separator (index);
--- a/libbirdxml/XmlString.vala +++ b/libbirdxml/XmlString.vala @@ -114,6 +114,21 @@ Posix.assert (len + offset < length); return new XmlString (data + offset, len); } + + internal int find_char (char needle) { + char* haystack = data; + char c = data[0]; + int i = 0; + + while (c != '\0') { + if (haystack[i] == needle) { + return i; + } + i++; + } + + return -1; + } public string to_string () { unowned string s = (string) data;