From 751f22590b9f062ba7e66336aa3d4bdfc567660c Mon Sep 17 00:00:00 2001 From: David Robillard Date: Tue, 21 Feb 2012 01:04:55 +0000 Subject: Avoid comparing against NS_XSD several times per node. git-svn-id: http://svn.drobilla.net/serd/trunk@315 490d8e77-9747-427b-9fa3-0b8f29cee8a0 --- src/writer.c | 12 ++++++------ 1 file 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'); -- cgit v1.2.1