summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorTom Hacohen <tom@stosb.com>2015-10-12 16:12:36 +0100
committerTom Hacohen <tom@stosb.com>2015-10-19 10:20:53 +0100
commite837a5e4ffa0b9a3fd4a8fd16452374dbd310476 (patch)
tree1ee7b186ee687273efce3d772941f6b54965ea2c /src
parent2eaf33d9cf05662d504166aad1bdcd9d9ccf5491 (diff)
Eo: Optimise object data fetching (minor).
Pre-calculate object data offset for improved performance.
Diffstat (limited to 'src')
-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 34713f3..f8ea428 100644
--- a/src/lib/eo/eo.c
+++ b/src/lib/eo/eo.c
@@ -1305,6 +1305,11 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...)
1305 klass->data_offset = klass->parent->data_offset + 1305 klass->data_offset = klass->parent->data_offset +
1306 EO_ALIGN_SIZE(klass->parent->desc->data_size); 1306 EO_ALIGN_SIZE(klass->parent->desc->data_size);
1307 } 1307 }
1308 else
1309 {
1310 /* Data starts after the object size. */
1311 klass->data_offset = _eo_sz;
1312 }
1308 1313
1309 mro = eina_list_remove(mro, NULL); 1314 mro = eina_list_remove(mro, NULL);
1310 mro = eina_list_prepend(mro, klass); 1315 mro = eina_list_prepend(mro, klass);
@@ -1359,7 +1364,7 @@ eo_class_new(const Eo_Class_Description *desc, const Eo_Class *parent_id, ...)
1359 extn_data_itr->offset = 0; 1364 extn_data_itr->offset = 0;
1360 } 1365 }
1361 1366
1362 klass->obj_size = _eo_sz + extn_data_off; 1367 klass->obj_size = extn_data_off;
1363 if (getenv("EO_DEBUG")) 1368 if (getenv("EO_DEBUG"))
1364 { 1369 {
1365 fprintf(stderr, "Eo class '%s' will take %u bytes per object.\n", 1370 fprintf(stderr, "Eo class '%s' will take %u bytes per object.\n",
@@ -1557,7 +1562,7 @@ static inline void *
1557_eo_data_scope_get(const _Eo_Object *obj, const _Eo_Class *klass) 1562_eo_data_scope_get(const _Eo_Object *obj, const _Eo_Class *klass)
1558{ 1563{
1559 if (EINA_LIKELY((klass->desc->data_size > 0) && (klass->desc->type != EO_CLASS_TYPE_MIXIN))) 1564 if (EINA_LIKELY((klass->desc->data_size > 0) && (klass->desc->type != EO_CLASS_TYPE_MIXIN)))
1560 return ((char *) obj) + _eo_sz + klass->data_offset; 1565 return ((char *) obj) + klass->data_offset;
1561 1566
1562 if (EINA_UNLIKELY(klass->desc->data_size == 0)) 1567 if (EINA_UNLIKELY(klass->desc->data_size == 0))
1563 { 1568 {
@@ -1573,7 +1578,7 @@ _eo_data_scope_get(const _Eo_Object *obj, const _Eo_Class *klass)
1573 while (doff_itr->klass) 1578 while (doff_itr->klass)
1574 { 1579 {
1575 if (doff_itr->klass == klass) 1580 if (doff_itr->klass == klass)
1576 return ((char *) obj) + _eo_sz + doff_itr->offset; 1581 return ((char *) obj) + doff_itr->offset;
1577 doff_itr++; 1582 doff_itr++;
1578 } 1583 }
1579 } 1584 }