diff options
author | David Robillard <d@drobilla.net> | 2018-05-12 13:01:10 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2018-05-27 18:23:15 +0200 |
commit | 9767db1b2d1dffc4847f162c857cfcb0ab3141bc (patch) | |
tree | a5a1cb11abae9e1de1f2159de3f44febd92dafb7 | |
parent | 20c01ada2d0304cc4e3faa9ed1a6c5726365e2c0 (diff) | |
download | serd-9767db1b2d1dffc4847f162c857cfcb0ab3141bc.tar.gz serd-9767db1b2d1dffc4847f162c857cfcb0ab3141bc.tar.bz2 serd-9767db1b2d1dffc4847f162c857cfcb0ab3141bc.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)); |