summaryrefslogtreecommitdiff
path: root/plmeta.c
diff options
context:
space:
mode:
authorGravatar waker <wakeroid@gmail.com>2011-04-26 22:31:06 +0200
committerGravatar waker <wakeroid@gmail.com>2011-04-26 22:31:06 +0200
commitd95b00a4d606b97469fb38c69de66915ae9a0dd0 (patch)
tree49257fe2e501f7c4a6dc8c3ed17f90e1c731ea41 /plmeta.c
parent9d63b3e8d5466c0c9a775eb0d1f159e2aa575f66 (diff)
optimized search
Diffstat (limited to 'plmeta.c')
-rw-r--r--plmeta.c55
1 files changed, 27 insertions, 28 deletions
diff --git a/plmeta.c b/plmeta.c
index 6b287637..36e289e6 100644
--- a/plmeta.c
+++ b/plmeta.c
@@ -30,6 +30,8 @@ void
pl_add_meta (playItem_t *it, const char *key, const char *value) {
LOCK;
// check if it's already set
+ DB_metaInfo_t *normaltail = NULL;
+ DB_metaInfo_t *propstart = NULL;
DB_metaInfo_t *tail = NULL;
DB_metaInfo_t *m = it->meta;
while (m) {
@@ -38,6 +40,15 @@ pl_add_meta (playItem_t *it, const char *key, const char *value) {
UNLOCK;
return;
}
+ // find end of normal metadata
+ if (!normaltail && (m->key[0] == ':' || m->key[0] == '_')) {
+ normaltail = tail;
+ propstart = m;
+ if (key[0] != ':' && key[0] != '_') {
+ break;
+ }
+ }
+ // find end of properties
tail = m;
m = m->next;
}
@@ -46,40 +57,28 @@ pl_add_meta (playItem_t *it, const char *key, const char *value) {
if (!value || !*value) {
UNLOCK;
return;
-#if 0
- if (!strcasecmp (key, "title")) {
- // cut filename without path and extension
- const char *pext = pl_find_meta (it, ":URI") + strlen (pl_find_meta (it, ":URI")) - 1;
- while (pext >= pl_find_meta (it, ":URI") && *pext != '.') {
- pext--;
- }
- const char *pname = pext;
- while (pname >= pl_find_meta (it, ":URI") && *pname != '/') {
- pname--;
- }
- if (*pname == '/') {
- pname++;
- }
- strncpy (str, pname, pext-pname);
- str[pext-pname] = 0;
- value = str;
- }
- else {
- UNLOCK;
- return;
- }
-#endif
}
m = malloc (sizeof (DB_metaInfo_t));
memset (m, 0, sizeof (DB_metaInfo_t));
- m->key = metacache_add_string (key); //key;
- m->value = metacache_add_string (value); //strdup (value);
+ m->key = metacache_add_string (key);
+ m->value = metacache_add_string (value);
- if (tail) {
- tail->next = m;
+ if (key[0] == ':' || key[0] == '_') {
+ if (tail) {
+ tail->next = m;
+ }
+ else {
+ it->meta = m;
+ }
}
else {
- it->meta = m;
+ m->next = propstart;
+ if (normaltail) {
+ normaltail->next = m;
+ }
+ else {
+ it->meta = m;
+ }
}
UNLOCK;
}