jpeg pushed a commit to branch master.

http://git.enlightenment.org/core/efl.git/commit/?id=b676dcf9982292c08227f7133fb97d4bf31b7ebe

commit b676dcf9982292c08227f7133fb97d4bf31b7ebe
Author: Jean-Philippe Andre <jp.an...@samsung.com>
Date:   Fri Jun 26 10:40:27 2015 +0900

    Edje: Use array instead of hash for filters data
    
    Yeah that was totally overkill and pure laziness on my side.
    
    Despite having the EO API for the filters still in beta,
    I want to the EDC API and EDJ binary formats to stay compatible,
    so let's get it right before the release :)
---
 src/bin/edje/edje_cc_handlers.c | 24 ++++++++++++++----------
 src/lib/edje/edje_calc.c        | 35 +++++++++++++++++------------------
 src/lib/edje/edje_data.c        | 14 +++++++++++---
 src/lib/edje/edje_private.h     | 13 ++++++++++++-
 4 files changed, 54 insertions(+), 32 deletions(-)

diff --git a/src/bin/edje/edje_cc_handlers.c b/src/bin/edje/edje_cc_handlers.c
index 7834ffb..114a085 100644
--- a/src/bin/edje/edje_cc_handlers.c
+++ b/src/bin/edje/edje_cc_handlers.c
@@ -11703,8 +11703,10 @@ 
st_collections_group_parts_part_description_filter_source(void)
 static void
 st_collections_group_parts_part_description_filter_data(void)
 {
+   Edje_Part_Description_Spec_Filter_Data *array;
    Edje_Part_Description_Spec_Filter *filter;
    char *name, *value;
+   unsigned k;
 
    if (current_part->type == EDJE_PART_TYPE_TEXT)
      filter = &(((Edje_Part_Description_Text *)current_desc)->text.filter);
@@ -11719,19 +11721,21 @@ 
st_collections_group_parts_part_description_filter_data(void)
 
    check_arg_count(2);
 
-   if (!filter->data)
-     filter->data = eina_hash_string_small_new(EINA_FREE_CB(free));
-
    name = parse_str(0);
    value = parse_str(1);
-   if (eina_hash_find(filter->data, name))
-     {
-        ERR("parse error %s:%i. filter.data '%s' already exists in this 
context",
-            file_in, line - 1, name);
-        exit(-1);
-     }
+   for (k = 0; k < filter->data_count; k++)
+     if (!strcmp(filter->data[k].name, name))
+       {
+          ERR("parse error %s:%i. filter.data '%s' already exists in this 
context",
+              file_in, line - 1, name);
+          exit(-1);
+       }
 
-   eina_hash_add(filter->data, name, value);
+   filter->data_count++;
+   array = realloc(filter->data, 
sizeof(Edje_Part_Description_Spec_Filter_Data) * filter->data_count);
+   array[filter->data_count - 1].name = name;
+   array[filter->data_count - 1].value = value;
+   filter->data = array;
 }
 
 /** @edcsubsection{collections_group_parts_descriptions_params,
diff --git a/src/lib/edje/edje_calc.c b/src/lib/edje/edje_calc.c
index b0db961..c72bba7 100644
--- a/src/lib/edje/edje_calc.c
+++ b/src/lib/edje/edje_calc.c
@@ -2480,27 +2480,27 @@ _edje_part_recalc_single_filter(Edje *ed,
          /* pass extra data items */
          if (filter->data)
            {
-              Eina_Iterator *it = eina_hash_iterator_tuple_new(filter->data);
-              Eina_Hash_Tuple *tup;
-              EINA_ITERATOR_FOREACH(it, tup)
+              unsigned int k;
+              for (k = 0; k < filter->data_count; k++)
                 {
-                   const char *name = tup->key;
-                   char *value = tup->data;
-                   if (!value)
+                   Edje_Part_Description_Spec_Filter_Data *data = 
&(filter->data[k]);
+                   if (data->invalid_cc)
+                     continue;
+                   if (!data->value)
                      {
-                        efl_gfx_filter_data_set(name, NULL, EINA_FALSE);
+                        efl_gfx_filter_data_set(data->name, NULL, EINA_FALSE);
                      }
-                   else if (!strncmp(value, "color_class('", 
sizeof("color_class('") - 1))
+                   else if (!strncmp(data->value, "color_class('", 
sizeof("color_class('") - 1))
                      {
                         /* special handling for color classes even tho they're 
not that great */
                         char *ccname, *buffer, *r;
                         Edje_Color_Class *cc;
 
-                        ccname = strdup(value + sizeof("color_class('") - 1);
+                        ccname = strdup(data->value + sizeof("color_class('") 
- 1);
                         if (ccname)
                           {
                              r = strchr(ccname, '\'');
-                             if (r)
+                             if (r && (r[1] == ')') && (r[2] == '\0'))
                                {
                                   *r = '\0';
                                   cc = _edje_color_class_find(ed, ccname);
@@ -2511,33 +2511,32 @@ _edje_part_recalc_single_filter(Edje *ed,
                                              "r2=%d,g2=%d,b2=%d,a2=%d,"
                                              "r3=%d,g3=%d,b3=%d,a3=%d}";
                                        int len = sizeof(fmt) + 20;
-                                       len += strlen(name);
+                                       len += strlen(data->name);
                                        buffer = alloca(len);
-                                       snprintf(buffer, len - 1, fmt, name,
+                                       snprintf(buffer, len - 1, fmt, 
data->name,
                                                 (int) cc->r, (int) cc->g, 
(int) cc->b, (int) cc->a,
                                                 (int) cc->r2, (int) cc->g2, 
(int) cc->b2, (int) cc->a2,
                                                 (int) cc->r3, (int) cc->g3, 
(int) cc->b3, (int) cc->a3);
                                        buffer[len - 1] = 0;
-                                       efl_gfx_filter_data_set(name, buffer, 
EINA_TRUE);
+                                       efl_gfx_filter_data_set(data->name, 
buffer, EINA_TRUE);
                                     }
                                   else
                                     {
                                        ERR("Unknown color class: %s", ccname);
-                                       eina_hash_del(filter->data, tup->key, 
tup->data);
+                                       data->invalid_cc = EINA_TRUE;
                                     }
                                }
                              else
                                {
-                                  ERR("Failed to parse color class: %s", 
value);
-                                  eina_hash_del(filter->data, tup->key, 
tup->data);
+                                  ERR("Failed to parse color class: %s", 
data->value);
+                                  data->invalid_cc = EINA_TRUE;
                                }
                              free(ccname);
                           }
                      }
                    else
-                     efl_gfx_filter_data_set(name, value, EINA_FALSE);
+                     efl_gfx_filter_data_set(data->name, data->value, 
EINA_FALSE);
                 }
-              eina_iterator_free(it);
            }
          efl_gfx_filter_program_set(code, filter->name);
          if (prev_sources != filter_sources)
diff --git a/src/lib/edje/edje_data.c b/src/lib/edje/edje_data.c
index 55f06ba..d4671a9 100644
--- a/src/lib/edje/edje_data.c
+++ b/src/lib/edje/edje_data.c
@@ -67,6 +67,7 @@ Eet_Data_Descriptor 
*_edje_edd_edje_part_description_external_pointer = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_part_description_mesh_node_pointer = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_part_description_light_pointer = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_part_description_camera_pointer = NULL;
+Eet_Data_Descriptor *_edje_edd_edje_part_description_filter_data = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_part_image_id = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_part_image_id_pointer = NULL;
 Eet_Data_Descriptor *_edje_edd_edje_external_param = NULL;
@@ -280,6 +281,7 @@ _edje_edd_shutdown(void)
    FREED(_edje_edd_edje_part_description_mesh_node_pointer);
    FREED(_edje_edd_edje_part_description_light_pointer);
    FREED(_edje_edd_edje_part_description_camera_pointer);
+   FREED(_edje_edd_edje_part_description_filter_data);
    FREED(_edje_edd_edje_part_image_id);
    FREED(_edje_edd_edje_part_image_id_pointer);
    FREED(_edje_edd_edje_external_param);
@@ -511,6 +513,12 @@ _edje_edd_init(void)
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, 
"a3", a3, EET_T_UCHAR);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_color_class, Edje_Color_Class, 
"desc", desc, EET_T_STRING);
 
+   /* evas filters */
+   EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, 
Edje_Part_Description_Spec_Filter_Data);
+   _edje_edd_edje_part_description_filter_data = 
eet_data_descriptor_file_new(&eddc);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_filter_data, 
Edje_Part_Description_Spec_Filter_Data, "name", name, EET_T_STRING);
+   EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_filter_data, 
Edje_Part_Description_Spec_Filter_Data, "value", value, EET_T_STRING);
+
    /* the main file directory */
    EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_File);
    eddc.func.hash_add = (void * (*)(void *, const char *, void 
*))_edje_eina_hash_add_alloc;
@@ -958,8 +966,8 @@ _edje_edd_init(void)
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, 
Edje_Part_Description_Image, "image.fill.spread", image.fill.spread, EET_T_INT);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, 
Edje_Part_Description_Image, "image.fill.type", image.fill.type, EET_T_CHAR);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_image, 
Edje_Part_Description_Image, "image.filter.code", image.filter.code, 
EET_T_STRING);
-   EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_edje_edd_edje_part_description_image, 
Edje_Part_Description_Image, "image.filter.sources", image.filter.sources);
-   EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_description_image, 
Edje_Part_Description_Image, "image.filter.data", image.filter.data);
+   EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_edje_edd_edje_part_description_image, 
Edje_Part_Description_Image, "image.filter.sources", image.filter.sources); // 
@since 1.15
+   EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_description_image, 
Edje_Part_Description_Image, "image.filter.data", image.filter.data, 
_edje_edd_edje_part_description_filter_data); // @since 1.15
 
    EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Proxy);
    eddc.func.mem_free = mem_free_proxy;
@@ -1018,7 +1026,7 @@ _edje_edd_init(void)
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, 
Edje_Part_Description_Text, "text.ellipsis", text.ellipsis, EET_T_DOUBLE);
    EET_DATA_DESCRIPTOR_ADD_BASIC(_edje_edd_edje_part_description_text, 
Edje_Part_Description_Text, "text.filter", text.filter.code, EET_T_STRING);
    EET_DATA_DESCRIPTOR_ADD_LIST_STRING(_edje_edd_edje_part_description_text, 
Edje_Part_Description_Text, "text.filter_sources", text.filter.sources);
-   EET_DATA_DESCRIPTOR_ADD_HASH_STRING(_edje_edd_edje_part_description_text, 
Edje_Part_Description_Text, "text.filter.data", text.filter.data); // @since 
1.15
+   EET_DATA_DESCRIPTOR_ADD_VAR_ARRAY(_edje_edd_edje_part_description_text, 
Edje_Part_Description_Text, "text.filter.data", text.filter.data, 
_edje_edd_edje_part_description_filter_data); // @since 1.15
 
    EET_EINA_FILE_DATA_DESCRIPTOR_CLASS_SET(&eddc, Edje_Part_Description_Text);
    eddc.func.mem_free = mem_free_textblock;
diff --git a/src/lib/edje/edje_private.h b/src/lib/edje/edje_private.h
index 824d2c4..ff44bcd 100644
--- a/src/lib/edje/edje_private.h
+++ b/src/lib/edje/edje_private.h
@@ -360,6 +360,7 @@ typedef struct _Edje_Part_Description_Spec_Mesh_Node 
Edje_Part_Description_Spec_
 typedef struct _Edje_Part_Description_Spec_Light     
Edje_Part_Description_Spec_Light;
 typedef struct _Edje_Part_Description_Spec_Camera    
Edje_Part_Description_Spec_Camera;
 typedef struct _Edje_Part_Description_Spec_Filter    
Edje_Part_Description_Spec_Filter;
+typedef struct _Edje_Part_Description_Spec_Filter_Data 
Edje_Part_Description_Spec_Filter_Data;
 typedef struct _Edje_Physics_Face                    Edje_Physics_Face;
 typedef struct _Edje_Patterns                        Edje_Patterns;
 typedef struct _Edje_Part_Box_Animation              Edje_Part_Box_Animation;
@@ -1279,12 +1280,22 @@ struct _Edje_Part_Description_Spec_Border
    FLOAT_T        scale_by; /* when border scale above is enabled, border 
width OUTPUT is scaled by the object or global scale factor. this value adds 
another multiplier that the global scale is multiplued by first. if <= 0.0 it 
is not used, and if 1.0 it i s "ineffective" */
 };
 
+struct _Edje_Part_Description_Spec_Filter_Data
+{
+   Eina_Stringshare *name;
+   Eina_Stringshare *value;
+   // below data not in edj
+   Eina_Bool         invalid_cc : 1;
+};
+
 struct _Edje_Part_Description_Spec_Filter
 {
    const char    *code;
    const char    *name;
    Eina_List     *sources; /* "part" or "buffer:part" */
-   Eina_Hash     *data; /* "name" --> "data" */
+   Edje_Part_Description_Spec_Filter_Data *data; /* array */
+   unsigned int   data_count;
+   // below data not in edj
    Eina_Bool      checked_data : 1; // checked whether this is a data item or 
embedded string
    Eina_Bool      sources_set : 1;
    Eina_Bool      no_free : 1;

-- 


Reply via email to