diff options
author | tasn <tasn> | 2012-09-03 07:26:57 +0000 |
---|---|---|
committer | tasn <tasn@7cbeb6ba-43b4-40fd-8cce-4c39aea84d33> | 2012-09-03 07:26:57 +0000 |
commit | 190a6714c6c48005d69bef159bb23c5a0c0ee676 (patch) | |
tree | ceb58b8c16b8fa6d70d90839a0e156e337a541db | |
parent | a8895a126992e5c5411513b5ef1a53dd2561b276 (diff) | |
download | eobj-190a6714c6c48005d69bef159bb23c5a0c0ee676.tar.gz eobj-190a6714c6c48005d69bef159bb23c5a0c0ee676.tar.bz2 eobj-190a6714c6c48005d69bef159bb23c5a0c0ee676.zip |
Eo: optimised eo_op_class_get a bit. Can still make it better.
git-svn-id: http://svn.enlightenment.org/svn/e/trunk/PROTO/eobj@75960 7cbeb6ba-43b4-40fd-8cce-4c39aea84d33
-rw-r--r-- | src/lib/eo.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/src/lib/eo.c b/src/lib/eo.c index 9ece6f2..98a0631 100644 --- a/src/lib/eo.c +++ b/src/lib/eo.c @@ -203,20 +203,24 @@ static const Eo_Class * _eo_op_class_get(Eo_Op op) { /* FIXME: Make it fast. */ - const Eo_Class *klass = NULL; Eo_Class **itr = _eo_classes; - Eo_Class_Id i; - for (i = 0 ; i < _eo_classes_last_id ; i++, itr++) + int mid, max, min; + + min = 0; + max = _eo_classes_last_id - 1; + while (min <= max) { - if (*itr && ((*itr)->base_id <= op) && - (op <= (*itr)->base_id + (*itr)->desc->ops.count)) - { - klass = *itr; - return klass; - } + mid = (min + max) / 2; + + if (itr[mid]->base_id + itr[mid]->desc->ops.count < op) + min = mid + 1; + else if (itr[mid]->base_id > op) + max = mid - 1; + else + return itr[mid]; } - return klass; + return NULL; } static const Eo_Op_Description * |