edje - reduce memory footprint by rearranging structs and types 64/82064/2
authorCarsten Haitzler (Rasterman) <raster@rasterman.com>
Mon, 4 Jul 2016 05:59:59 +0000 (14:59 +0900)
committerJaehwan Kim <jae.hwan.kim@samsung.com>
Wed, 3 Aug 2016 09:26:06 +0000 (02:26 -0700)
this should cut some memory used by edje by using smaller types like
shorts instead of ints where we just dont need a full int range and
short will do, and re-ordering in memory data soit packs better when
accoutning for alignment

Change-Id: Ia4b6755b0056cd6e9dc3260775a6c2bbb01ddd0c

src/lib/edje/edje_edit.c

index c89d4b4..85851b0 100644 (file)
@@ -782,7 +782,7 @@ _edje_fix_parts_id(Edje *ed)
     */
    unsigned int i;
    int correct_id;
-   unsigned int count;
+   unsigned short count;
 
    //printf("FIXING PARTS ID \n");
 
@@ -805,7 +805,7 @@ _edje_fix_parts_id(Edje *ed)
      }
 
    /* If we have removed some parts realloc table_parts */
-   count = ed->collection->parts_count;
+   count = (unsigned short)ed->collection->parts_count;
    if (count != ed->table_parts_size)
      {
         ed->table_parts = realloc(ed->table_parts, sizeof(Edje_Real_Part *) * count);
@@ -2988,7 +2988,7 @@ EAPI Eina_List *
 edje_edit_parts_list_get(Evas_Object *obj)
 {
    Eina_List *parts = NULL;
-   unsigned int i;
+   unsigned short i;
 
    GET_ED_OR_RETURN(NULL);
 
@@ -3055,6 +3055,7 @@ _edje_edit_real_part_add(Evas_Object *obj, const char *name, Edje_Part_Type type
 
    GET_ED_OR_RETURN(EINA_FALSE);
 
+   if (ed->table_parts_size == 0xffff) return EINA_FALSE;
    //printf("ADD PART: %s [type: %d]\n", name, type);
 
    /* Check if part already exists */
@@ -3259,7 +3260,7 @@ edje_edit_part_del(Evas_Object *obj, const char *part)
    Edje_Part *ep;
    unsigned int k;
    unsigned int id;
-   unsigned int i;
+   unsigned short i;
 
    GET_EED_OR_RETURN(EINA_FALSE);
    GET_RP_OR_RETURN(EINA_FALSE);
@@ -3470,7 +3471,7 @@ edje_edit_part_above_get(Evas_Object *obj, const char *part)
 
    GET_RP_OR_RETURN(0);
 
-   if ((unsigned int)rp->part->id >= ed->table_parts_size - 1) return 0;
+   if ((unsigned short)rp->part->id >= ed->table_parts_size - 1) return 0;
 
    next = ed->table_parts[(rp->part->id + 1) % ed->table_parts_size];
 
@@ -3561,7 +3562,7 @@ edje_edit_part_restack_above(Evas_Object *obj, const char *part)
 
    //printf("RESTACK PART: %s ABOVE\n", part);
 
-   if ((unsigned int)rp->part->id >= ed->table_parts_size - 1) return EINA_FALSE;
+   if ((unsigned short)rp->part->id >= ed->table_parts_size - 1) return EINA_FALSE;
 
    group = ed->collection;
 
@@ -7955,7 +7956,7 @@ edje_edit_state_text_set(Evas_Object *obj, const char *part, const char *state,
 {
    Edje_Part_Description_Text *txt;
    Edje_Real_Part *real;
-   unsigned int i;
+   unsigned short i;
 
    if (!text)
      return EINA_FALSE;
@@ -12009,7 +12010,8 @@ edje_edit_source_generate(Evas_Object *obj)
    Edje_Part_Description_Common *part_desc;
    Edje_Part_Description_Image *part_desc_image;
    Edje_Part_Description_Text *part_desc_text;
-   unsigned int i, j;
+   unsigned short i;
+   unsigned int j;
    const char *entry;
    const char *str;
    Eina_Strbuf *buf = NULL;