From 6be4a34047af74c984dc644b4157da0b45c6dd83 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 14 Nov 2020 11:18:42 +0100 Subject: Simplify abbreviated URI writing code --- src/writer.c | 27 ++++++++++++++------------- 1 file changed, 14 insertions(+), 13 deletions(-) (limited to 'src') diff --git a/src/writer.c b/src/writer.c index 10d5eed9..451b3e13 100644 --- a/src/writer.c +++ b/src/writer.c @@ -510,19 +510,20 @@ write_uri_node(SerdWriter* const writer, } const bool has_scheme = serd_uri_string_has_scheme(node->buf); - if (field == FIELD_PREDICATE && supports_abbrev(writer) - && !strcmp((const char*)node->buf, NS_RDF "type")) { - return sink("a", 1, writer) == 1; - } else if (supports_abbrev(writer) - && !strcmp((const char*)node->buf, NS_RDF "nil")) { - return sink("()", 2, writer) == 2; - } else if (has_scheme && (writer->style & SERD_STYLE_CURIED) && - serd_env_qualify(writer->env, node, &prefix, &suffix) && - is_name(suffix.buf, suffix.len)) { - write_uri(writer, prefix.buf, prefix.n_bytes); - sink(":", 1, writer); - write_uri(writer, suffix.buf, suffix.len); - return true; + if (supports_abbrev(writer)) { + if (field == FIELD_PREDICATE && + !strcmp((const char*)node->buf, NS_RDF "type")) { + return sink("a", 1, writer) == 1; + } else if (!strcmp((const char*)node->buf, NS_RDF "nil")) { + return sink("()", 2, writer) == 2; + } else if (has_scheme && (writer->style & SERD_STYLE_CURIED) && + serd_env_qualify(writer->env, node, &prefix, &suffix) && + is_name(suffix.buf, suffix.len)) { + write_uri(writer, prefix.buf, prefix.n_bytes); + sink(":", 1, writer); + write_uri(writer, suffix.buf, suffix.len); + return true; + } } write_sep(writer, SEP_URI_BEGIN); -- cgit v1.2.1