diff options
author | David Robillard <d@drobilla.net> | 2018-05-12 13:01:10 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-12-30 17:58:17 -0500 |
commit | 9c4bb09bd9fa42ca54c71e27f59e0cc81a528f37 (patch) | |
tree | 4cf5768069726842e74ab73e8acb6eefe231a353 | |
parent | c6daba398ccff8674978fc4efcdfc3e95272726c (diff) | |
download | serd-9c4bb09bd9fa42ca54c71e27f59e0cc81a528f37.tar.gz serd-9c4bb09bd9fa42ca54c71e27f59e0cc81a528f37.tar.bz2 serd-9c4bb09bd9fa42ca54c71e27f59e0cc81a528f37.zip |
Avoid copying nodes when equivalent prefixes are set
-rw-r--r-- | src/env.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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)); |