From 9c4bb09bd9fa42ca54c71e27f59e0cc81a528f37 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 12 May 2018 13:01:10 +0200 Subject: Avoid copying nodes when equivalent prefixes are set --- src/env.c | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/src/env.c b/src/env.c index 6f241f7d..c9982c22 100644 --- a/src/env.c +++ b/src/env.c @@ -120,9 +120,11 @@ serd_env_add(SerdEnv* env, const char* name_str = serd_node_get_string(name); SerdPrefix* const prefix = serd_env_find(env, name_str, name->n_bytes); if (prefix) { - SerdNode* old_prefix_uri = prefix->uri; - prefix->uri = serd_node_copy(uri); - serd_node_free(old_prefix_uri); + if (!serd_node_equals(prefix->uri, uri)) { + SerdNode* old_prefix_uri = prefix->uri; + prefix->uri = serd_node_copy(uri); + serd_node_free(old_prefix_uri); + } } else { env->prefixes = (SerdPrefix*)realloc( env->prefixes, (++env->n_prefixes) * sizeof(SerdPrefix)); -- cgit v1.2.1