aboutsummaryrefslogtreecommitdiffstats
path: root/src/writer.c
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2012-02-21 01:04:55 +0000
committerDavid Robillard <d@drobilla.net>2012-02-21 01:04:55 +0000
commit751f22590b9f062ba7e66336aa3d4bdfc567660c (patch)
tree0f6f869d7319b874b850a1c6a2bbfdc63cb43939 /src/writer.c
parent945ce48b31a50e5973bdf97b47336a9bcd2410bf (diff)
downloadserd-751f22590b9f062ba7e66336aa3d4bdfc567660c.tar.gz
serd-751f22590b9f062ba7e66336aa3d4bdfc567660c.tar.bz2
serd-751f22590b9f062ba7e66336aa3d4bdfc567660c.zip
Avoid comparing against NS_XSD several times per node.
git-svn-id: http://svn.drobilla.net/serd/trunk@315 490d8e77-9747-427b-9fa3-0b8f29cee8a0
Diffstat (limited to 'src/writer.c')
-rw-r--r--src/writer.c12
1 files changed, 6 insertions, 6 deletions
diff --git a/src/writer.c b/src/writer.c
index 587a3e3f..15b6e445 100644
--- a/src/writer.c
+++ b/src/writer.c
@@ -355,17 +355,17 @@ write_node(SerdWriter* writer,
break;
case SERD_LITERAL:
if (writer->syntax == SERD_TURTLE && datatype && datatype->buf) {
- // TODO: compare against NS_XSD prefix once
- if (!strcmp((const char*)datatype->buf, NS_XSD "boolean")
- || !strcmp((const char*)datatype->buf, NS_XSD "decimal")
- || !strcmp((const char*)datatype->buf, NS_XSD "integer")) {
+ const char* type_uri = (const char*)datatype->buf;
+ if (!strncmp(type_uri, NS_XSD, sizeof(NS_XSD) - 1) && (
+ !strcmp(type_uri + sizeof(NS_XSD) - 1, "boolean") ||
+ !strcmp(type_uri + sizeof(NS_XSD) - 1, "decimal") ||
+ !strcmp(type_uri + sizeof(NS_XSD) - 1, "integer"))) {
sink(node->buf, node->n_bytes, writer);
break;
}
}
if (writer->syntax != SERD_NTRIPLES
- && ((node->flags & SERD_HAS_NEWLINE)
- || (node->flags & SERD_HAS_QUOTE))) {
+ && (node->flags & (SERD_HAS_NEWLINE|SERD_HAS_QUOTE))) {
sink("\"\"\"", 3, writer);
write_text(writer, WRITE_LONG_STRING,
node->buf, node->n_bytes, '\0');