diff options
author | David Robillard <d@drobilla.net> | 2020-08-14 15:51:17 +0200 |
---|---|---|
committer | David Robillard <d@drobilla.net> | 2020-08-14 19:07:52 +0200 |
commit | 4b50e6ebdab57433fa60c2376719e51c79de7fe9 (patch) | |
tree | 52a704b3ae46c8eff78ca836c418477a4ea475db /src/env.c | |
parent | 54b9109a8e0fce21deb8082b9a53f419cb82fc27 (diff) | |
download | serd-4b50e6ebdab57433fa60c2376719e51c79de7fe9.tar.gz serd-4b50e6ebdab57433fa60c2376719e51c79de7fe9.tar.bz2 serd-4b50e6ebdab57433fa60c2376719e51c79de7fe9.zip |
Avoid copying nodes when equivalent prefixes are set
Diffstat (limited to 'src/env.c')
-rw-r--r-- | src/env.c | 8 |
1 files changed, 5 insertions, 3 deletions
@@ -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)); |