diff options
author | Tom Hacohen <tom@stosb.com> | 2012-09-03 07:26:57 +0000 |
---|---|---|
committer | Tom Hacohen <tom@stosb.com> | 2012-09-03 07:26:57 +0000 |
commit | b9e11cf26e7b8524c0c255bc1b426e88e4f40f76 (patch) | |
tree | 17a8f8942ea220c9438b01376455f01bc99d5c3e /legacy/eobj | |
parent | 76fc983dc9d16331ee46f3fdb46ea906016c16b2 (diff) |
Eo: optimised eo_op_class_get a bit. Can still make it better.
SVN revision: 75960
Diffstat (limited to 'legacy/eobj')
-rw-r--r-- | legacy/eobj/src/lib/eo.c | 24 |
1 files changed, 14 insertions, 10 deletions
diff --git a/legacy/eobj/src/lib/eo.c b/legacy/eobj/src/lib/eo.c index 9ece6f20c8..98a0631e77 100644 --- a/legacy/eobj/src/lib/eo.c +++ b/legacy/eobj/src/lib/eo.c | |||
@@ -203,20 +203,24 @@ static const Eo_Class * | |||
203 | _eo_op_class_get(Eo_Op op) | 203 | _eo_op_class_get(Eo_Op op) |
204 | { | 204 | { |
205 | /* FIXME: Make it fast. */ | 205 | /* FIXME: Make it fast. */ |
206 | const Eo_Class *klass = NULL; | ||
207 | Eo_Class **itr = _eo_classes; | 206 | Eo_Class **itr = _eo_classes; |
208 | Eo_Class_Id i; | 207 | int mid, max, min; |
209 | for (i = 0 ; i < _eo_classes_last_id ; i++, itr++) | 208 | |
209 | min = 0; | ||
210 | max = _eo_classes_last_id - 1; | ||
211 | while (min <= max) | ||
210 | { | 212 | { |
211 | if (*itr && ((*itr)->base_id <= op) && | 213 | mid = (min + max) / 2; |
212 | (op <= (*itr)->base_id + (*itr)->desc->ops.count)) | 214 | |
213 | { | 215 | if (itr[mid]->base_id + itr[mid]->desc->ops.count < op) |
214 | klass = *itr; | 216 | min = mid + 1; |
215 | return klass; | 217 | else if (itr[mid]->base_id > op) |
216 | } | 218 | max = mid - 1; |
219 | else | ||
220 | return itr[mid]; | ||
217 | } | 221 | } |
218 | 222 | ||
219 | return klass; | 223 | return NULL; |
220 | } | 224 | } |
221 | 225 | ||
222 | static const Eo_Op_Description * | 226 | static const Eo_Op_Description * |