summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@free.fr>2012-09-11 03:39:27 +0000
committerCedric BAIL <cedric.bail@free.fr>2012-09-11 03:39:27 +0000
commit2127cab57dceaf896a8177d0c331b3d5e6091210 (patch)
tree5225863377e0e42c8a92a5f0c7d97f9b667ddad8
parenta69160bb08a5b9c0ae616e3ac960dbe76bee0ff8 (diff)
edje: O(1) lookup for all access to Part_Lookup structure in edje_cc.
This will give a major boost of performance for all insanely huge theme you try to compile. Get down from 13s to 4s. Still some room for improvement. SVN revision: 76427
Diffstat (limited to '')
-rw-r--r--legacy/edje/ChangeLog3
-rw-r--r--legacy/edje/NEWS1
-rw-r--r--legacy/edje/src/bin/edje_cc_out.c150
3 files changed, 74 insertions, 80 deletions
diff --git a/legacy/edje/ChangeLog b/legacy/edje/ChangeLog
index b4139e7cad..746a195d36 100644
--- a/legacy/edje/ChangeLog
+++ b/legacy/edje/ChangeLog
@@ -606,3 +606,6 @@
606 it's map enabled by the edje, then edje needs to update it's uv mapping 606 it's map enabled by the edje, then edje needs to update it's uv mapping
607 info. 607 info.
608 608
6092012-09-11 Cedric Bail
610
611 * O(1) lookup used when searching Part_Lookup in edje_cc.
diff --git a/legacy/edje/NEWS b/legacy/edje/NEWS
index ad99c456f4..bb466489ee 100644
--- a/legacy/edje/NEWS
+++ b/legacy/edje/NEWS
@@ -11,6 +11,7 @@ Additions:
11 11
12Improvements: 12Improvements:
13 * Check the number of parameter for image in edc. 13 * Check the number of parameter for image in edc.
14 * O(1) lookup used when searching Part_Lookup in edje_cc.
14 15
15Fixes: 16Fixes:
16 17
diff --git a/legacy/edje/src/bin/edje_cc_out.c b/legacy/edje/src/bin/edje_cc_out.c
index ea8b07fade..812434db77 100644
--- a/legacy/edje/src/bin/edje_cc_out.c
+++ b/legacy/edje/src/bin/edje_cc_out.c
@@ -192,13 +192,15 @@ Eina_List *aliases = NULL;
192static Eet_Data_Descriptor *edd_edje_file = NULL; 192static Eet_Data_Descriptor *edd_edje_file = NULL;
193static Eet_Data_Descriptor *edd_edje_part_collection = NULL; 193static Eet_Data_Descriptor *edd_edje_part_collection = NULL;
194 194
195static Eina_List *part_lookups = NULL;
196static Eina_List *program_lookups = NULL; 195static Eina_List *program_lookups = NULL;
197static Eina_List *group_lookups = NULL; 196static Eina_List *group_lookups = NULL;
198static Eina_List *image_lookups = NULL; 197static Eina_List *image_lookups = NULL;
199static Eina_List *part_slave_lookups = NULL; 198static Eina_List *part_slave_lookups = NULL;
200static Eina_List *image_slave_lookups= NULL; 199static Eina_List *image_slave_lookups= NULL;
201 200
201static Eina_Hash *part_dest_lookup = NULL;
202static Eina_Hash *part_pc_dest_lookup = NULL;
203
202void 204void
203error_and_abort(Eet_File *ef __UNUSED__, const char *fmt, ...) 205error_and_abort(Eet_File *ef __UNUSED__, const char *fmt, ...)
204{ 206{
@@ -212,11 +214,50 @@ error_and_abort(Eet_File *ef __UNUSED__, const char *fmt, ...)
212 exit(-1); 214 exit(-1);
213} 215}
214 216
217static unsigned int
218_double_pointer_key_length(const void *key __UNUSED__)
219{
220 return sizeof (void*) * 2;
221}
222
223static int
224_double_pointer_key_cmp(const void *key1, int key1_length,
225 const void *key2, int key2_length __UNUSED__)
226{
227 return memcmp(key1, key2, key1_length);
228}
229
230static int
231_double_pointer_key_hash(const void *key, int key_length __UNUSED__)
232{
233#ifdef __LP64__
234 return eina_hash_int64(key, sizeof (void*)) ^
235 eina_hash_int64(((unsigned char) key) + sizeof (void*), sizeof (void*));
236#else
237 /* double 32 bits pointer is ... 64bits awesome ! */
238 return eina_hash_int64(key, key_length);
239#endif
240}
241
242static void
243data_part_lookup_free(Part_Lookup *pl)
244{
245 free(pl->name);
246 free(pl);
247}
248
215void 249void
216data_setup(void) 250data_setup(void)
217{ 251{
218 edd_edje_file = _edje_edd_edje_file; 252 edd_edje_file = _edje_edd_edje_file;
219 edd_edje_part_collection = _edje_edd_edje_part_collection; 253 edd_edje_part_collection = _edje_edd_edje_part_collection;
254
255 part_dest_lookup = eina_hash_pointer_new(EINA_FREE_CB(eina_list_free));
256 part_pc_dest_lookup = eina_hash_new(EINA_KEY_LENGTH(_double_pointer_key_length),
257 EINA_KEY_CMP(_double_pointer_key_cmp),
258 EINA_KEY_HASH(_double_pointer_key_hash),
259 EINA_FREE_CB(data_part_lookup_free),
260 8);
220} 261}
221 262
222static void 263static void
@@ -1737,111 +1778,58 @@ data_queue_group_lookup(const char *name, Edje_Part *part)
1737 gl->part = part; 1778 gl->part = part;
1738} 1779}
1739 1780
1740//#define NEWPARTLOOKUP 1
1741#ifdef NEWPARTLOOKUP
1742static Eina_Hash *_part_lookups_hash = NULL;
1743static Eina_Hash *_part_lookups_dest_hash = NULL;
1744#endif
1745
1746void 1781void
1747data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest) 1782data_queue_part_lookup(Edje_Part_Collection *pc, const char *name, int *dest)
1748{ 1783{
1784 void *key[2];
1749 Part_Lookup *pl = NULL; 1785 Part_Lookup *pl = NULL;
1750 Eina_List *l; 1786 Eina_List *list;
1751#ifdef NEWPARTLOOKUP 1787
1752 char buf[256]; 1788 key[0] = pc;
1753#endif 1789 key[1] = dest;
1754 1790
1755#ifdef NEWPARTLOOKUP 1791 pl = eina_hash_find(part_pc_dest_lookup, &key);
1756 snprintf(buf, sizeof(buf), "%lu-%lu",
1757 (unsigned long)name, (unsigned long)dest);
1758 if (_part_lookups_hash) pl = eina_hash_find(_part_lookups_hash, buf);
1759 if (pl) 1792 if (pl)
1760 { 1793 {
1761 free(pl->name); 1794 free(pl->name);
1762 if (name[0]) 1795 if (name[0])
1763 pl->name = mem_strdup(name);
1764 else
1765 { 1796 {
1766 eina_hash_del(_part_lookups_hash, buf, pl); 1797 pl->name = mem_strdup(name);
1767 snprintf(buf, sizeof(buf), "%lu", (unsigned long)dest);
1768 eina_hash_del(_part_lookups_dest_hash, buf, pl);
1769 part_lookups = eina_list_remove(part_lookups, pl);
1770 free(pl);
1771 } 1798 }
1772 return; 1799 else
1773 }
1774#else
1775 EINA_LIST_FOREACH(part_lookups, l, pl)
1776 {
1777 if ((pl->pc == pc) && (pl->dest == dest))
1778 { 1800 {
1779 free(pl->name); 1801 list = eina_hash_find(part_dest_lookup, &pl->dest);
1780 if (name[0]) 1802 list = eina_list_remove(list, pl);
1781 pl->name = mem_strdup(name); 1803 eina_hash_set(part_dest_lookup, &pl->dest, list);
1782 else 1804 free(pl);
1783 {
1784 part_lookups = eina_list_remove(part_lookups, pl);
1785 free(pl);
1786 }
1787 return;
1788 } 1805 }
1806 return ;
1789 } 1807 }
1790#endif 1808
1791 if (!name[0]) return; 1809 if (!name[0]) return;
1792 1810
1793 pl = mem_alloc(SZ(Part_Lookup)); 1811 pl = mem_alloc(SZ(Part_Lookup));
1794 part_lookups = eina_list_prepend(part_lookups, pl);
1795 pl->pc = pc; 1812 pl->pc = pc;
1796 pl->name = mem_strdup(name); 1813 pl->name = mem_strdup(name);
1797 pl->dest = dest; 1814 pl->dest = dest;
1798#ifdef NEWPARTLOOKUP
1799 if (!_part_lookups_hash)
1800 _part_lookups_hash = eina_hash_string_superfast_new(NULL);
1801 eina_hash_add(_part_lookups_hash, buf, pl);
1802 1815
1803 snprintf(buf, sizeof(buf), "%lu", (unsigned long)dest); 1816 eina_hash_add(part_pc_dest_lookup, &key, pl);
1804 if (!_part_lookups_dest_hash) 1817
1805 _part_lookups_dest_hash = eina_hash_string_superfast_new(NULL); 1818 list = eina_hash_find(part_dest_lookup, &pl->dest);
1806 l = eina_hash_find(_part_lookups_dest_hash, buf); 1819 list = eina_list_prepend(list, pl);
1807 if (l) 1820 eina_hash_set(part_dest_lookup, &pl->dest, list);
1808 {
1809 l = eina_list_append(l, pl);
1810 eina_hash_modify(_part_lookups_dest_hash, buf, l);
1811 }
1812 else
1813 {
1814 l = eina_list_append(l, pl);
1815 eina_hash_add(_part_lookups_dest_hash, buf, l);
1816 }
1817#endif
1818} 1821}
1819 1822
1820void 1823void
1821data_queue_copied_part_lookup(Edje_Part_Collection *pc, int *src, int *dest) 1824data_queue_copied_part_lookup(Edje_Part_Collection *pc, int *src, int *dest)
1822{ 1825{
1826 Eina_List *list;
1823 Eina_List *l; 1827 Eina_List *l;
1824 Part_Lookup *pl; 1828 Part_Lookup *pl;
1825#ifdef NEWPARTLOOKUP
1826 Eina_List *list;
1827 char buf[256];
1828#endif
1829 1829
1830#ifdef NEWPARTLOOKUP 1830 list = eina_hash_find(part_dest_lookup, &src);
1831 if (!_part_lookups_dest_hash) return;
1832 snprintf(buf, sizeof(buf), "%lu", (unsigned long)src);
1833 list = eina_hash_find(_part_lookups_dest_hash, buf);
1834 EINA_LIST_FOREACH(list, l, pl) 1831 EINA_LIST_FOREACH(list, l, pl)
1835 { 1832 data_queue_part_lookup(pc, pl->name, dest);
1836 data_queue_part_lookup(pc, pl->name, dest);
1837 }
1838#else
1839 EINA_LIST_FOREACH(part_lookups, l, pl)
1840 {
1841 if (pl->dest == src)
1842 data_queue_part_lookup(pc, pl->name, dest);
1843 }
1844#endif
1845} 1833}
1846 1834
1847void 1835void
@@ -2033,6 +2021,7 @@ void
2033data_process_lookups(void) 2021data_process_lookups(void)
2034{ 2022{
2035 Edje_Part_Collection *pc; 2023 Edje_Part_Collection *pc;
2024 Eina_Iterator *it;
2036 Part_Lookup *part; 2025 Part_Lookup *part;
2037 Program_Lookup *program; 2026 Program_Lookup *program;
2038 Group_Lookup *group; 2027 Group_Lookup *group;
@@ -2115,7 +2104,8 @@ data_process_lookups(void)
2115#undef PROGRAM_ID_SET 2104#undef PROGRAM_ID_SET
2116 } 2105 }
2117 2106
2118 EINA_LIST_FREE(part_lookups, part) 2107 it = eina_hash_iterator_data_new(part_pc_dest_lookup);
2108 EINA_ITERATOR_FOREACH(it, part)
2119 { 2109 {
2120 Edje_Part *ep; 2110 Edje_Part *ep;
2121 unsigned int i; 2111 unsigned int i;
@@ -2149,10 +2139,10 @@ data_process_lookups(void)
2149 exit(-1); 2139 exit(-1);
2150 } 2140 }
2151 } 2141 }
2152
2153 free(part->name);
2154 free(part);
2155 } 2142 }
2143 eina_iterator_free(it);
2144 eina_hash_free(part_dest_lookup);
2145 eina_hash_free(part_pc_dest_lookup);
2156 2146
2157 EINA_LIST_FREE(program_lookups, program) 2147 EINA_LIST_FREE(program_lookups, program)
2158 { 2148 {