summaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDavid Robillard <d@drobilla.net>2011-02-11 05:15:56 +0000
committerDavid Robillard <d@drobilla.net>2011-02-11 05:15:56 +0000
commit9749ab338c735f777be4fe6dc89082ea30044df1 (patch)
tree556314b7eb9d0472d06a78b003c56e820d6dd288 /src
parent28d3d1608126a676ea1d08249bac167bd5e88035 (diff)
downloadlilv-9749ab338c735f777be4fe6dc89082ea30044df1.tar.gz
lilv-9749ab338c735f777be4fe6dc89082ea30044df1.tar.bz2
lilv-9749ab338c735f777be4fe6dc89082ea30044df1.zip
Reduce internal use of _by_qname variants (unnecessary overhead).
git-svn-id: http://svn.drobilla.net/lad/trunk/slv2@2918 a436a847-0d15-0410-975c-d299462d15a1
Diffstat (limited to 'src')
-rw-r--r--src/plugin.c9
-rw-r--r--src/port.c30
-rw-r--r--src/slv2_internal.h3
-rw-r--r--src/world.c10
4 files changed, 35 insertions, 17 deletions
diff --git a/src/plugin.c b/src/plugin.c
index 0224b60..2bdae5c 100644
--- a/src/plugin.c
+++ b/src/plugin.c
@@ -381,7 +381,7 @@ slv2_plugin_verify(SLV2Plugin plugin)
}
slv2_values_free(results);
- results = slv2_plugin_get_value_by_qname(plugin, "doap:name");
+ results = slv2_plugin_get_value(plugin, plugin->world->doap_name_val);
if (!results) {
return false;
}
@@ -406,9 +406,10 @@ SLV2_API
SLV2Value
slv2_plugin_get_name(SLV2Plugin plugin)
{
- SLV2Values results = slv2_plugin_get_value_by_qname(plugin, "doap:name");
- SLV2Value ret = NULL;
+ SLV2Values results = slv2_plugin_get_value(plugin,
+ plugin->world->doap_name_val);
+ SLV2Value ret = NULL;
if (results) {
SLV2Value val = slv2_values_get_at(results, 0);
if (slv2_value_is_string(val))
@@ -418,7 +419,7 @@ slv2_plugin_get_name(SLV2Plugin plugin)
if (!ret)
SLV2_WARNF("<%s> has no (mandatory) doap:name\n",
- slv2_value_as_string(slv2_plugin_get_uri(plugin)));
+ slv2_value_as_string(slv2_plugin_get_uri(plugin)));
return ret;
}
diff --git a/src/port.c b/src/port.c
index 2ee3337..615d38f 100644
--- a/src/port.c
+++ b/src/port.c
@@ -199,19 +199,21 @@ SLV2Value
slv2_port_get_name(SLV2Plugin p,
SLV2Port port)
{
- SLV2Value ret = NULL;
- SLV2Values results = slv2_port_get_value_by_qname(p, port, "lv2:name");
-
- if (results && slv2_values_size(results) > 0) {
- ret = slv2_value_duplicate(slv2_values_get_at(results, 0));
- } else {
- results = slv2_port_get_value_by_qname(p, port, "lv2:name");
- if (results && slv2_values_size(results) > 0)
- ret = slv2_value_duplicate(slv2_values_get_at(results, 0));
+ SLV2Values results = slv2_port_get_value(p, port,
+ p->world->lv2_name_val);
+
+ SLV2Value ret = NULL;
+ if (results) {
+ SLV2Value val = slv2_values_get_at(results, 0);
+ if (slv2_value_is_string(val))
+ ret = slv2_value_duplicate(val);
+ slv2_values_free(results);
}
- slv2_values_free(results);
-
+ if (!ret)
+ SLV2_WARNF("<%s> has no (mandatory) doap:name\n",
+ slv2_value_as_string(slv2_plugin_get_uri(p)));
+
return ret;
}
@@ -301,6 +303,10 @@ SLV2Values
slv2_port_get_properties(SLV2Plugin p,
SLV2Port port)
{
- return slv2_port_get_value_by_qname(p, port, "lv2:portProperty");
+ SLV2Value pred = slv2_value_new_from_node(
+ p->world, p->world->lv2_portproperty_node);
+ SLV2Values ret = slv2_port_get_value(p, port, pred);
+ slv2_value_free(pred);
+ return ret;
}
diff --git a/src/slv2_internal.h b/src/slv2_internal.h
index 12a32a0..4424467 100644
--- a/src/slv2_internal.h
+++ b/src/slv2_internal.h
@@ -40,6 +40,7 @@ extern "C" {
#include "lv2/lv2plug.in/ns/ext/dyn-manifest/dyn-manifest.h"
#endif
+#define SLV2_NS_DOAP (const uint8_t*)"http://usefulinc.com/ns/doap#"
#define SLV2_NS_RDFS (const uint8_t*)"http://www.w3.org/2000/01/rdf-schema#"
#define SLV2_NS_SLV2 (const uint8_t*)"http://drobilla.net/ns/slv2#"
#define SLV2_NS_LV2 (const uint8_t*)"http://lv2plug.in/ns/lv2core#"
@@ -202,6 +203,8 @@ struct _SLV2World {
SLV2Node slv2_dmanifest_node;
SLV2Node xsd_integer_node;
SLV2Node xsd_decimal_node;
+ SLV2Value doap_name_val;
+ SLV2Value lv2_name_val;
bool filter_language;
};
diff --git a/src/world.c b/src/world.c
index ae04b17..6cb0bad 100644
--- a/src/world.c
+++ b/src/world.c
@@ -56,7 +56,9 @@ slv2_world_new()
#define NS_DYNMAN (const uint8_t*)"http://lv2plug.in/ns/ext/dynmanifest#"
-#define NEW_URI(uri) sord_get_uri(world->model, true, uri)
+#define NEW_URI(uri) sord_get_uri(world->model, true, uri)
+#define NEW_URI_VAL(uri) slv2_value_new_from_node( \
+ world,sord_get_uri(world->model, true, uri));
world->dyn_manifest_node = NEW_URI(NS_DYNMAN "DynManifest");
world->lv2_specification_node = NEW_URI(SLV2_NS_LV2 "Specification");
@@ -81,6 +83,9 @@ slv2_world_new()
world->xsd_integer_node = NEW_URI(SLV2_NS_XSD "integer");
world->xsd_decimal_node = NEW_URI(SLV2_NS_XSD "decimal");
+ world->doap_name_val = NEW_URI_VAL(SLV2_NS_DOAP "name");
+ world->lv2_name_val = NEW_URI_VAL(SLV2_NS_LV2 "name");
+
world->lv2_plugin_class = slv2_plugin_class_new(
world, NULL, world->lv2_plugin_node, "Plugin");
assert(world->lv2_plugin_class);
@@ -133,6 +138,9 @@ slv2_world_free(SLV2World world)
slv2_node_free(world->xsd_integer_node);
slv2_node_free(world->xsd_decimal_node);
+ slv2_value_free(world->doap_name_val);
+ slv2_value_free(world->lv2_name_val);
+
for (unsigned i = 0; i < ((GPtrArray*)world->plugins)->len; ++i)
slv2_plugin_free(g_ptr_array_index((GPtrArray*)world->plugins, i));
g_ptr_array_unref(world->plugins);