summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-12 16:12:36 +0100
committerTom Hacohen <tom@stosb.com>2015-11-09 11:43:04 +0000
commit1ed0edfb9eff9796443078497bc7c088da32f378 (patch)
tree84960767f7c6167373dc0435fee99df10a9e8405
parent5e870cd388444a57ff27c9d29e48b9b20683a766 (diff)
Eo: Optimise object data fetching (minor).
Pre-calculate object data offset for improved performance.
-rw-r--r--src/lib/eo/eo.c11
1 files changed, 8 insertions, 3 deletions
diff --git a/src/lib/eo/eo.c b/src/lib/eo/eo.c
index 22120cd788..0f8b0659fd 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -1352,6 +1352,11 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...)
1352 klass->data_offset = klass->parent->data_offset + 1352 klass->data_offset = klass->parent->data_offset +
1353 EO_ALIGN_SIZE(klass->parent->desc->data_size); 1353 EO_ALIGN_SIZE(klass->parent->desc->data_size);
1354 } 1354 }
1355 else
1356 {
1357 /* Data starts after the object size. */
1358 klass->data_offset = _eo_sz;
1359 }
1355 1360
1356 mro = eina_list_remove(mro, NULL); 1361 mro = eina_list_remove(mro, NULL);
1357 mro = eina_list_prepend(mro, klass); 1362 mro = eina_list_prepend(mro, klass);
@@ -1406,7 +1411,7 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...)
1406 extn_data_itr->offset = 0; 1411 extn_data_itr->offset = 0;
1407 } 1412 }
1408 1413
1409 klass->obj_size = _eo_sz + extn_data_off; 1414 klass->obj_size = extn_data_off;
1410 if (getenv("EO_DEBUG")) 1415 if (getenv("EO_DEBUG"))
1411 { 1416 {
1412 fprintf(stderr, "Eo class '%s' will take %u bytes per object.\n", 1417 fprintf(stderr, "Eo class '%s' will take %u bytes per object.\n",
@@ -1604,7 +1609,7 @@ static inline void *
1604_eo_data_scope_get(const _Eo_Object *obj, const _Eo_Class *klass) 1609_eo_data_scope_get(const _Eo_Object *obj, const _Eo_Class *klass)
1605{ 1610{
1606 if (EINA_LIKELY((klass->desc->data_size > 0) && (klass->desc->type != EO_CLASS_TYPE_MIXIN))) 1611 if (EINA_LIKELY((klass->desc->data_size > 0) && (klass->desc->type != EO_CLASS_TYPE_MIXIN)))
1607 return ((char *) obj) + _eo_sz + klass->data_offset; 1612 return ((char *) obj) + klass->data_offset;
1608 1613
1609 if (EINA_UNLIKELY(klass->desc->data_size == 0)) 1614 if (EINA_UNLIKELY(klass->desc->data_size == 0))
1610 { 1615 {
@@ -1620,7 +1625,7 @@ _eo_data_scope_get(const _Eo_Object *obj, const _Eo_Class *klass)
1620 while (doff_itr->klass) 1625 while (doff_itr->klass)
1621 { 1626 {
1622 if (doff_itr->klass == klass) 1627 if (doff_itr->klass == klass)
1623 return ((char *) obj) + _eo_sz + doff_itr->offset; 1628 return ((char *) obj) + doff_itr->offset;
1624 doff_itr++; 1629 doff_itr++;
1625 } 1630 }
1626 } 1631 }