From 7be3dda58ae6e091334fa72ab3cadd32a0a44c77 Mon Sep 17 00:00:00 2001 From: handa Date: Fri, 25 May 2007 12:57:39 +0000 Subject: [PATCH] (mdebug__unregister_object): Small optimization. --- src/m17n-core.c | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) diff --git a/src/m17n-core.c b/src/m17n-core.c index 66fef04..6257ad9 100644 --- a/src/m17n-core.c +++ b/src/m17n-core.c @@ -490,11 +490,15 @@ mdebug__unregister_object (M17NObjectArray *array, void *object) array->count--; if (array->count >= 0) { - int i = 0; + int i; - while (i < array->used && array->objects[i] != object) i++; - if (i < array->used) - array->objects[i] = NULL; + for (i = array->used - 1; i >= 0 && array->objects[i] != object; i--); + if (i >= 0) + { + if (i == array->used - 1) + array->used--; + array->objects[i] = NULL; + } else mdebug_hook (); } -- 1.7.10.4