summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorJérémy Zurcher <jeremy@asynk.ch>2013-06-14 14:59:22 +0200
committerJérémy Zurcher <jeremy@asynk.ch>2013-06-14 14:59:22 +0200
commit551a77fa0f08584266e1340ef1cf2455d6be0bc2 (patch)
tree7132deb83d12ff78b8045d44ad966006b1c04af7
parent85103b5cdd4c764eb7e56de2e5dfea35bfe9d1b1 (diff)
downloadefl-551a77fa0f08584266e1340ef1cf2455d6be0bc2.tar.gz
eo: speed up mixin offset table creation
-rw-r--r--src/lib/eo/eo.c46
1 files changed, 17 insertions, 29 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 244f52241b..4bc55585ca 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -844,7 +844,7 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...)
_Eo_Class *klass;
va_list p_list;
size_t extn_sz, mro_sz;
- Eina_List *extn_list, *mro;
+ Eina_List *extn_list, *mro, *mixins;
_Eo_Class *parent = _eo_class_pointer_get(parent_id);
if (parent && !EINA_MAGIC_CHECK(parent, EO_CLASS_EINA_MAGIC))
@@ -972,14 +972,21 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...)
}
}
- /* Copy the mro and free the list. */
+ /* Copy the mro and free the list.
+ * in the same time build the mixin table
+ */
{
+ mixins = NULL;
const _Eo_Class *kls_itr;
const _Eo_Class **mro_itr = klass->mro;
EINA_LIST_FREE(mro, kls_itr)
{
*(mro_itr++) = kls_itr;
+ if ((kls_itr->desc->type == EO_CLASS_TYPE_MIXIN) &&
+ (kls_itr->desc->data_size > 0))
+ mixins = eina_list_append(mixins, kls_itr);
+
DBG("Added '%s' to MRO", kls_itr->desc->name);
}
}
@@ -989,40 +996,21 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...)
/* create MIXIN offset table. */
{
- const _Eo_Class **mro_itr = klass->mro;
+ const _Eo_Class *kls_itr;
Eo_Extension_Data_Offset *extn_data_itr;
- size_t extn_num = 0;
- /* FIXME: Make faster... */
- while (*mro_itr)
- {
- if (((*mro_itr)->desc->type == EO_CLASS_TYPE_MIXIN) &&
- ((*mro_itr)->desc->data_size > 0))
- {
- extn_num++;
- }
- mro_itr++;
- }
-
- klass->extn_data_off = calloc(extn_num + 1,
- sizeof(*klass->extn_data_off));
+ klass->extn_data_off = calloc(eina_list_count(mixins) + 1,
+ sizeof(*klass->extn_data_off));
extn_data_itr = klass->extn_data_off;
- mro_itr = klass->mro;
- while (*mro_itr)
+ EINA_LIST_FREE(mixins, kls_itr)
{
- if (((*mro_itr)->desc->type == EO_CLASS_TYPE_MIXIN) &&
- ((*mro_itr)->desc->data_size > 0))
- {
- extn_data_itr->klass = *mro_itr;
- extn_data_itr->offset = extn_data_off;
+ extn_data_itr->klass = kls_itr;
+ extn_data_itr->offset = extn_data_off;
- extn_data_off += EO_ALIGN_SIZE(extn_data_itr->klass->desc->data_size);
- extn_data_itr++;
- }
- mro_itr++;
+ extn_data_off += EO_ALIGN_SIZE(extn_data_itr->klass->desc->data_size);
+ extn_data_itr++;
}
-
}
klass->obj_size = _eo_sz + extn_data_off;