From 4b50e6ebdab57433fa60c2376719e51c79de7fe9 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Fri, 14 Aug 2020 15:51:17 +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 09a91d6a..19e2abe8 100644 --- a/src/env.c +++ b/src/env.c @@ -112,9 +112,11 @@ serd_env_add(SerdEnv* env, { SerdPrefix* const prefix = serd_env_find(env, name->buf, 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