Commit 47a29f39 authored by Hanspeter Portner's avatar Hanspeter Portner

Merge commit 'e0538e0d'

parents d9bae3fa e0538e0d
Pipeline #36001430 failed with stages
in 4 minutes and 27 seconds
......@@ -120,12 +120,12 @@ struct _props_t {
uint32_t max_size;
unsigned nimpls;
props_impl_t impls [0];
props_impl_t impls [1];
};
#define PROPS_T(PROPS, MAX_NIMPLS) \
props_t (PROPS); \
props_impl_t _impls [(MAX_NIMPLS)]
props_impl_t _impls [(MAX_NIMPLS-1)]
// rt-safe
static inline int
......@@ -223,52 +223,40 @@ _props_restoring_set(props_t *props)
atomic_store_explicit(&props->restoring, true, memory_order_release);
}
static inline void
_props_qsort(props_impl_t *A, int n)
static inline props_impl_t *
_props_impl_get(props_t *props, LV2_URID property)
{
if(n < 2)
return;
const props_impl_t *p = A;
int i = -1;
int j = n;
while(true)
for(unsigned i = 0, idx = (property + i) % props->nimpls;
i < props->nimpls;
i++, idx = (property + i) % props->nimpls)
{
do {
i += 1;
} while(A[i].property < p->property);
props_impl_t *impl = &props->impls[idx];
do {
j -= 1;
} while(A[j].property > p->property);
if(i >= j)
break;
const props_impl_t tmp = A[i];
A[i] = A[j];
A[j] = tmp;
if(impl->property == property)
{
return impl;
}
}
_props_qsort(A, j + 1);
_props_qsort(A + j + 1, n - j - 1);
return NULL;
}
static inline props_impl_t *
_props_bsearch(props_t *props, LV2_URID property)
_props_impl_add(props_t *props, LV2_URID property)
{
props_impl_t *base = props->impls;
for(int N = props->nimpls, half; N > 1; N -= half)
for(unsigned i = 0, idx = (property + i) % props->nimpls;
i < props->nimpls;
i++, idx = (property + i) % props->nimpls)
{
half = N/2;
props_impl_t *dst = &base[half];
base = (dst->property > property) ? base : dst;
props_impl_t *impl = &props->impls[idx];
if(impl->property == 0)
{
return impl;
}
}
return (base->property == property) ? base : NULL;
return NULL;
}
static inline LV2_Atom_Forge_Ref
......@@ -417,7 +405,7 @@ static inline int
_props_impl_init(props_t *props, props_impl_t *impl, const props_def_t *def,
void *value_base, void *stash_base, LV2_URID_Map *map)
{
if(!def->property || !def->type)
if(!impl || !def->property || !def->type)
return 0;
const LV2_URID type = map->map(map->handle, def->type);
......@@ -536,14 +524,14 @@ props_init(props_t *props, const char *subject,
int status = 1;
for(unsigned i = 0; i < props->nimpls; i++)
{
props_impl_t *impl = &props->impls[i];
const props_def_t *def = &defs[i];
const LV2_URID property = map->map(map->handle, def->property);
props_impl_t *impl = _props_impl_add(props, property);
status = status
&& _props_impl_init(props, impl, &defs[i], value_base, stash_base, map);
&& _props_impl_init(props, impl, def, value_base, stash_base, map);
}
_props_qsort(props->impls, props->nimpls);
return status;
}
......@@ -624,7 +612,7 @@ props_advance(props_t *props, LV2_Atom_Forge *forge, uint32_t frames,
}
else if(property->atom.type == props->urid.atom_urid)
{
props_impl_t *impl = _props_bsearch(props, property->body);
props_impl_t *impl = _props_impl_get(props, property->body);
if(impl)
{
......@@ -680,7 +668,7 @@ props_advance(props_t *props, LV2_Atom_Forge *forge, uint32_t frames,
return 0;
}
props_impl_t *impl = _props_bsearch(props, property->body);
props_impl_t *impl = _props_impl_get(props, property->body);
if(impl && (impl->access == props->urid.patch_writable) )
{
_props_impl_set(props, impl, value->type, value->size,
......@@ -743,7 +731,7 @@ props_advance(props_t *props, LV2_Atom_Forge *forge, uint32_t frames,
const LV2_URID property = prop->key;
const LV2_Atom *value = &prop->value;
props_impl_t *impl = _props_bsearch(props, property);
props_impl_t *impl = _props_impl_get(props, property);
if(impl && (impl->access == props->urid.patch_writable) )
{
_props_impl_set(props, impl, value->type, value->size,
......@@ -770,7 +758,7 @@ static inline void
props_set(props_t *props, LV2_Atom_Forge *forge, uint32_t frames,
LV2_URID property, LV2_Atom_Forge_Ref *ref)
{
props_impl_t *impl = _props_bsearch(props, property);
props_impl_t *impl = _props_impl_get(props, property);
if(impl)
{
......@@ -784,7 +772,7 @@ props_set(props_t *props, LV2_Atom_Forge *forge, uint32_t frames,
static inline void
props_stash(props_t *props, LV2_URID property)
{
props_impl_t *impl = _props_bsearch(props, property);
props_impl_t *impl = _props_impl_get(props, property);
if(impl)
_props_impl_stash(props, impl);
......@@ -807,7 +795,7 @@ props_map(props_t *props, const char *uri)
static inline const char *
props_unmap(props_t *props, LV2_URID property)
{
props_impl_t *impl = _props_bsearch(props, property);
props_impl_t *impl = _props_impl_get(props, property);
if(impl)
return impl->def->property;
......
......@@ -147,6 +147,6 @@ props:test
props:statInt 4 ;
props:statFloat "0.4"^^xsd:float ;
props:statString "Hello world" ;
props:statPath <props.ttl> ;
props:statPath <file://tmp/props.ttl> ;
props:statChunk "AQIDBAUGBw=="^^xsd:base64Binary ;
] .
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment