From 15f9b09510615f1732e7eb043ac587673b4edc4a Mon Sep 17 00:00:00 2001 From: David Robillard Date: Mon, 31 Jan 2011 01:34:19 +0000 Subject: Reduce heavy use of librdf_new_node_from* functions. Store a librdf_node, rather than a librdf_uri, for a URI SLV2Value (further reducing the use of librdf_uri). git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2882 a436a847-0d15-0410-975c-d299462d15a1 --- src/value.c | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) (limited to 'src/value.c') diff --git a/src/value.c b/src/value.c index b1e141c..4f9d606 100644 --- a/src/value.c +++ b/src/value.c @@ -75,9 +75,11 @@ slv2_value_new(SLV2World world, SLV2ValueType type, const char* str) switch (type) { case SLV2_VALUE_URI: - val->val.uri_val = librdf_new_uri(world->world, (const uint8_t*)str); + val->val.uri_val = librdf_new_node_from_uri_string( + world->world, (const uint8_t*)str); assert(val->val.uri_val); - val->str_val = (char*)librdf_uri_as_string(val->val.uri_val); + val->str_val = (char*)librdf_uri_as_string( + librdf_node_get_uri(val->val.uri_val)); break; case SLV2_VALUE_QNAME_UNUSED: case SLV2_VALUE_BLANK: @@ -149,8 +151,9 @@ slv2_value_new_librdf_uri(SLV2World world, librdf_node* node) assert(node && librdf_node_is_resource(node)); SLV2Value val = (SLV2Value)malloc(sizeof(struct _SLV2Value)); val->type = SLV2_VALUE_URI; - val->val.uri_val = librdf_new_uri_from_uri(librdf_node_get_uri(node)); - val->str_val = (char*)librdf_uri_as_string(val->val.uri_val); + val->val.uri_val = librdf_new_node_from_node(node); + val->str_val = (char*)librdf_uri_as_string( + librdf_node_get_uri(val->val.uri_val)); return val; } @@ -201,8 +204,9 @@ slv2_value_duplicate(SLV2Value val) result->type = val->type; if (val->type == SLV2_VALUE_URI) { - result->val.uri_val = librdf_new_uri_from_uri(val->val.uri_val); - result->str_val = (char*)librdf_uri_as_string(val->val.uri_val); + result->val.uri_val = librdf_new_node_from_node(val->val.uri_val); + result->str_val = (char*)librdf_uri_as_string( + librdf_node_get_uri(val->val.uri_val)); } else { result->str_val = strdup(val->str_val); result->val = val->val; @@ -217,7 +221,7 @@ slv2_value_free(SLV2Value val) { if (val) { if (val->type == SLV2_VALUE_URI) - librdf_free_uri(val->val.uri_val); + librdf_free_node(val->val.uri_val); else free(val->str_val); @@ -238,7 +242,7 @@ slv2_value_equals(SLV2Value value, SLV2Value other) switch (value->type) { case SLV2_VALUE_URI: - return (librdf_uri_equals(value->val.uri_val, other->val.uri_val) != 0); + return (librdf_node_equals(value->val.uri_val, other->val.uri_val) != 0); case SLV2_VALUE_BLANK: case SLV2_VALUE_STRING: case SLV2_VALUE_QNAME_UNUSED: @@ -322,7 +326,7 @@ librdf_uri* slv2_value_as_librdf_uri(SLV2Value value) { assert(slv2_value_is_uri(value)); - return value->val.uri_val; + return librdf_node_get_uri(value->val.uri_val); } -- cgit v1.2.1