From 1c1c060d7a449952051b2dd78176e48db53df1c4 Mon Sep 17 00:00:00 2001 From: David Robillard Date: Sat, 20 Feb 2021 20:10:57 -0500 Subject: WIP: Make serd_env_expand() always return a node if it is not relative The old interface was potentially faster, because it avoided unnecessary copies, but was annoying to use and problematic because nodes that don't need expansion were indistinguishable from nodes that failed to expand (like those that use undefined namespace prefixes). In the grand scheme of things, the potential performance improvement isn't worth it, and unexpected unexpanded nodes causes deep nightmarish problems, so just make serd_env_expand() copy the input if it doesn't need expansion to make the API simpler and safer. --- include/serd/serd.h | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) (limited to 'include') diff --git a/include/serd/serd.h b/include/serd/serd.h index cfdc8693..a2e767ff 100644 --- a/include/serd/serd.h +++ b/include/serd/serd.h @@ -1062,13 +1062,15 @@ serd_env_qualify(const SerdEnv* SERD_NULLABLE env, const SerdNode* SERD_NONNULL uri); /** - Expand `node`, transforming CURIEs into URIs. + Expand `node`, transforming CURIEs and URI references into absolute URIs. If `node` is a relative URI reference, it is expanded to a full URI if possible. If `node` is a literal, its datatype is expanded if necessary. If `node` is a CURIE, it is expanded to a full URI if possible. - Returns null if `node` can not be expanded. + For simple nodes that do not require expansion, a copy is returned. Null is + returned if `node` is/contains a CURIE or relative URI that can not be + expanded. */ SERD_API SerdNode* SERD_ALLOCATED -- cgit v1.2.1