aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2023-02-24 11:40:06 -0500
committerDavid Robillard <d@drobilla.net>2023-12-02 18:49:07 -0500
commitd35082a57adac79703f2c9bb72da468172a209c5 (patch)
tree216f2cc7db12a07d398196cce4942b4a2380869d
parent3ae0e3a1f77e514dc7169e02d39964080e5e7ef9 (diff)
downloadserd-d35082a57adac79703f2c9bb72da468172a209c5.tar.gz
serd-d35082a57adac79703f2c9bb72da468172a209c5.tar.bz2
serd-d35082a57adac79703f2c9bb72da468172a209c5.zip
Improve URI read performance
-rw-r--r--src/read_ntriples.c27
1 files changed, 12 insertions, 15 deletions
diff --git a/src/read_ntriples.c b/src/read_ntriples.c
index 96748d64..df9a0e91 100644
--- a/src/read_ntriples.c
+++ b/src/read_ntriples.c
@@ -118,9 +118,6 @@ read_IRIREF_suffix(SerdReader* const reader, SerdNode* const node)
while (st <= SERD_FAILURE) {
const int c = eat_byte(reader);
switch (c) {
- case EOF:
- return r_err(reader, SERD_BAD_SYNTAX, "unexpected end of file");
-
case ' ':
case '"':
case '<':
@@ -136,34 +133,34 @@ read_IRIREF_suffix(SerdReader* const reader, SerdNode* const node)
return SERD_SUCCESS;
case '\\':
- TRY(st, read_UCHAR(reader, node, &code));
-
- if (!code || code == ' ' || code == '<' || code == '>') {
+ if (!(st = read_UCHAR(reader, node, &code)) &&
+ (code == ' ' || code == '<' || code == '>')) {
return r_err(
reader, SERD_BAD_SYNTAX, "U+%04X is not a valid IRI character", code);
}
-
break;
default:
- if (c <= 0x20) {
+ if (c >= 0x80) {
+ st = read_utf8_continuation(reader, node, (uint8_t)c);
+ } else if (c > 0x20) {
+ st = push_byte(reader, node, c);
+ } else if (c < 0) {
+ st = r_err(reader, SERD_BAD_SYNTAX, "unexpected end of file");
+ } else {
st = r_err(reader,
SERD_BAD_SYNTAX,
"control character U+%04X is not a valid IRI character",
(uint32_t)c);
- if (reader->strict) {
- return st;
+ if (!reader->strict) {
+ st = push_byte(reader, node, c);
}
}
-
- st = ((uint8_t)c & 0x80)
- ? read_utf8_continuation(reader, node, (uint8_t)c)
- : push_byte(reader, node, c);
}
}
- return tolerate_status(reader, st) ? SERD_SUCCESS : st;
+ return st;
}
/**