aboutsummaryrefslogtreecommitdiff
path: root/props.lv2
diff options
context:
space:
mode:
authorGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2016-08-27 10:12:09 +0200
committerGravatar Hanspeter Portner <dev@open-music-kontrollers.ch>2016-08-27 10:12:09 +0200
commit1a395727927d4151fe366b3c8141dbdf7b0f5903 (patch)
treeb9f0fbbfcbf38396d1fd97379722d97dd8fbb144 /props.lv2
parenteabc7b1094402fdfbb443953de396f85c471af6a (diff)
parent86459c062692d24409cc382e9eeb97cf68462ad0 (diff)
downloadsynthpod-1a395727927d4151fe366b3c8141dbdf7b0f5903.zip
synthpod-1a395727927d4151fe366b3c8141dbdf7b0f5903.tar.gz
synthpod-1a395727927d4151fe366b3c8141dbdf7b0f5903.tar.bz2
synthpod-1a395727927d4151fe366b3c8141dbdf7b0f5903.tar.xz
Merge commit '86459c062692d24409cc382e9eeb97cf68462ad0'
Diffstat (limited to 'props.lv2')
-rw-r--r--props.lv2/props.h38
1 files changed, 12 insertions, 26 deletions
diff --git a/props.lv2/props.h b/props.lv2/props.h
index 4ec4129..8f46d46 100644
--- a/props.lv2/props.h
+++ b/props.lv2/props.h
@@ -514,23 +514,16 @@ _type_qsort(props_type_t *a, unsigned n)
static inline props_type_t *
_type_bsearch(LV2_URID p, props_type_t *a, unsigned n)
{
- unsigned start = 0;
- unsigned end = n;
+ props_type_t *base = a;
- while(start < end)
+ for(unsigned N = n, half; N > 1; N -= half)
{
- const unsigned mid = start + (end - start)/2;
- props_type_t *dst = &a[mid];
-
- if(p < dst->urid)
- end = mid;
- else if(p > dst->urid)
- start = mid + 1;
- else
- return dst;
+ half = N/2;
+ props_type_t *dst = &base[half];
+ base = (dst->urid > p) ? base : dst;
}
- return NULL;
+ return (base->urid == p) ? base : NULL;
}
static inline void
@@ -565,23 +558,16 @@ _impl_qsort(props_impl_t *a, unsigned n)
static inline props_impl_t *
_impl_bsearch(LV2_URID p, props_impl_t *a, unsigned n)
{
- unsigned start = 0;
- unsigned end = n;
+ props_impl_t *base = a;
- while(start < end)
+ for(unsigned N = n, half; N > 1; N -= half)
{
- const unsigned mid = start + (end - start)/2;
- props_impl_t *dst = &a[mid];
-
- if(p < dst->property)
- end = mid;
- else if(p > dst->property)
- start = mid + 1;
- else
- return dst;
+ half = N/2;
+ props_impl_t *dst = &base[half];
+ base = (dst->property > p) ? base : dst;
}
- return NULL;
+ return (base->property == p) ? base : NULL;
}
static inline props_impl_t *