From 40a7b9aa38675b2f1c7059f96209087a7fc61910 Mon Sep 17 00:00:00 2001 From: Gustavo Sverzut Barbieri Date: Sun, 7 Mar 2010 04:50:12 +0000 Subject: [PATCH] color class lookup speedups by using stringshare properties. with stringshare, we can just compare pointers instead of strcmp. Since we'll need the stringshare later, this is a good optimization. SVN revision: 46925 --- legacy/edje/src/lib/edje_util.c | 13 ++++++++----- 1 file changed, 8 insertions(+), 5 deletions(-) diff --git a/legacy/edje/src/lib/edje_util.c b/legacy/edje/src/lib/edje_util.c index f6528e9d2a..a85b548679 100644 --- a/legacy/edje/src/lib/edje_util.c +++ b/legacy/edje/src/lib/edje_util.c @@ -661,10 +661,14 @@ edje_object_color_class_set(Evas_Object *obj, const char *color_class, int r, in else if (b > 255) b = 255; if (a < 0) a = 0; else if (a > 255) a = 255; + color_class = eina_stringshare_add(color_class); + if (!color_class) return EINA_FALSE; EINA_LIST_FOREACH(ed->color_classes, l, cc) { - if ((cc->name) && (!strcmp(cc->name, color_class))) + if (cc->name == color_class) { + eina_stringshare_del(color_class); + if ((cc->r == r) && (cc->g == g) && (cc->b == b) && (cc->a == a) && (cc->r2 == r2) && (cc->g2 == g2) && @@ -693,13 +697,12 @@ edje_object_color_class_set(Evas_Object *obj, const char *color_class, int r, in } } cc = malloc(sizeof(Edje_Color_Class)); - if (!cc) return EINA_FALSE; - cc->name = eina_stringshare_add(color_class); - if (!cc->name) + if (!cc) { - free(cc); + eina_stringshare_del(color_class); return EINA_FALSE; } + cc->name = color_class; cc->r = r; cc->g = g; cc->b = b;