aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2020-11-13 12:17:29 +0100
committerDavid Robillard <d@drobilla.net>2020-11-13 12:53:28 +0100
commitccdafafb818b8714f2f1cfced187955ba0aad85b (patch)
tree05f9556d4dbae0c64a5fc03f14ac8e40b63beae2 /src
parent41130751fb2a08c67c1ffedb6575f178692977a7 (diff)
downloadserd-ccdafafb818b8714f2f1cfced187955ba0aad85b.tar.gz
serd-ccdafafb818b8714f2f1cfced187955ba0aad85b.tar.bz2
serd-ccdafafb818b8714f2f1cfced187955ba0aad85b.zip
Improve IRI reading performance
This allows the compiler to construct a jump table, and avoids a branch.
Diffstat (limited to 'src')
-rw-r--r--src/n3.c23
1 files changed, 13 insertions, 10 deletions
diff --git a/src/n3.c b/src/n3.c
index f2c42081..81ec5d56 100644
--- a/src/n3.c
+++ b/src/n3.c
@@ -690,7 +690,8 @@ read_IRIREF(SerdReader* reader, Ref* dest)
while (!st) {
const int c = eat_byte_safe(reader, peek_byte(reader));
switch (c) {
- case '"': case '<': case '^': case '`': case '{': case '|': case '}':
+ case '"':
+ case '<':
*dest = pop_node(reader, *dest);
return r_err(reader, SERD_ERR_BAD_SYNTAX,
"invalid IRI character `%c'\n", c);
@@ -711,17 +712,19 @@ read_IRIREF(SerdReader* reader, Ref* dest)
break;
}
break;
+ case '^':
+ case '`':
+ case '{':
+ case '|':
+ case '}':
+ *dest = pop_node(reader, *dest);
+ return r_err(reader, SERD_ERR_BAD_SYNTAX,
+ "invalid IRI character `%c'\n", c);
default:
if (c <= 0x20) {
- if (is_print(c)) {
- r_err(reader, SERD_ERR_BAD_SYNTAX,
- "invalid IRI character `%c' (escape %%%02X)\n",
- c, (unsigned)c);
- } else {
- r_err(reader, SERD_ERR_BAD_SYNTAX,
- "invalid IRI character (escape %%%02X)\n",
- (unsigned)c);
- }
+ r_err(reader, SERD_ERR_BAD_SYNTAX,
+ "invalid IRI character (escape %%%02X)\n",
+ (unsigned)c);
if (reader->strict) {
*dest = pop_node(reader, *dest);
return SERD_ERR_BAD_SYNTAX;