summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-04-29 23:02:24 +0000
committerDavid Robillard <d@drobilla.net>2011-04-29 23:02:24 +0000
commit2aebf86c27288254da4765116686101a88840cbd (patch)
tree78beebd64ac17141a804471896f8389285395f6e /src
parentf89cead131a61c0b58bc4e706df339db3f1b9965 (diff)
downloadlilv-2aebf86c27288254da4765116686101a88840cbd.tar.gz
lilv-2aebf86c27288254da4765116686101a88840cbd.tar.bz2
lilv-2aebf86c27288254da4765116686101a88840cbd.zip
Faster implementations of lilv_plugin_get_one and lilv_plugin_get_unique.
git-svn-id: http://svn.drobilla.net/lad/trunk/lilv@3239 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/plugin.c40
-rw-r--r--src/world.c2
2 files changed, 19 insertions, 23 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 5841bd2..32c40da 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -81,35 +81,31 @@ lilv_plugin_free(LilvPlugin* p)
free(p);
}
-LilvNode*
-lilv_plugin_get_unique(const LilvPlugin* p,
- const SordNode* subject,
- const SordNode* predicate)
+static LilvNode*
+lilv_plugin_get_one(const LilvPlugin* p,
+ const SordNode* subject,
+ const SordNode* predicate)
{
- LilvNodes* values = lilv_world_query_values(p->world,
- subject, predicate, NULL);
- if (!values || lilv_nodes_size(values) != 1) {
- LILV_ERRORF("Port does not have exactly one `%s' property\n",
- sord_node_get_string(predicate));
- return NULL;
+ LilvNode* ret = NULL;
+ SordIter* stream = lilv_world_query(p->world, subject, predicate, NULL);
+ if (!lilv_matches_end(stream)) {
+ ret = lilv_node_new_from_node(p->world, lilv_match_object(stream));
}
- LilvNode* ret = lilv_node_duplicate(lilv_nodes_get_first(values));
- lilv_nodes_free(values);
+ lilv_match_end(stream);
return ret;
}
-static LilvNode*
-lilv_plugin_get_one(const LilvPlugin* p,
- const SordNode* subject,
- const SordNode* predicate)
+LilvNode*
+lilv_plugin_get_unique(const LilvPlugin* p,
+ const SordNode* subject,
+ const SordNode* predicate)
{
- LilvNodes* values = lilv_world_query_values(p->world,
- subject, predicate, NULL);
- if (!values) {
- return NULL;
+ LilvNode* ret = lilv_plugin_get_one(p, subject, predicate);
+ if (!ret) {
+ LILV_ERRORF("Multiple values found for (%s %s ...) property\n",
+ sord_node_get_string(subject),
+ sord_node_get_string(predicate));
}
- LilvNode* ret = lilv_node_duplicate(lilv_nodes_get_first(values));
- lilv_nodes_free(values);
return ret;
}
diff --git a/src/world.c b/src/world.c
index 5d093d0..336970f 100644
--- a/src/world.c
+++ b/src/world.c
@@ -744,7 +744,7 @@ lilv_world_load_all(LilvWorld* world)
LILV_FOREACH(plugins, p, world->plugins) {
const LilvPlugin* plugin = lilv_collection_get(world->plugins, p);
- const LilvNode* plugin_uri = lilv_plugin_get_uri(plugin);
+ const LilvNode* plugin_uri = lilv_plugin_get_uri(plugin);
// ?new dc:replaces plugin
SordIter* replacement = lilv_world_find_statements(