aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorCedric BAIL <cedric.bail@samsung.com>2013-03-19 21:15:44 +0900
committerChris Michael <cp.michael@samsung.com>2013-03-26 08:53:33 +0000
commit5d64aa33a32f6284b3fe50bc22e0ec829a2402d3 (patch)
tree9db80b10432f9feb30751d525150d81e7735525e
parentecore: include mman.h also when Evil is found. (diff)
downloadefl-5d64aa33a32f6284b3fe50bc22e0ec829a2402d3.tar.gz
eina: improve speed of Eina_Cow.
* Use an Eina_Hash for the garbage collector list. * Turn off garbage collection on object that are unlikely to match. This patch make 1.8 as fast as 1.7 again.
-rw-r--r--src/lib/eina/eina_cow.c20
-rw-r--r--src/lib/eina/eina_cow.h6
-rw-r--r--src/lib/evas/include/evas_private.h5
-rw-r--r--src/tests/eina/eina_test_cow.c10
4 files changed, 25 insertions, 16 deletions
diff --git a/src/lib/eina/eina_cow.c b/src/lib/eina/eina_cow.c
index c1573ffade..59d2cf78d3 100644
--- a/src/lib/eina/eina_cow.c
+++ b/src/lib/eina/eina_cow.c
@@ -20,6 +20,14 @@
# include "config.h"
#endif
+#ifdef HAVE_BACKTRACE
+# include <execinfo.h>
+#endif
+
+#ifndef NVALGRIND
+# include <memcheck.h>
+#endif
+
#include "eina_config.h"
#include "eina_private.h"
#include "eina_log.h"
@@ -31,13 +39,6 @@
#include "eina_cow.h"
-#ifndef NVALGRIND
-# include <memcheck.h>
-#endif
-
-#ifdef HAVE_BACKTRACE
-# include <execinfo.h>
-#endif
#ifdef EINA_COW_MAGIC_ON
#define EINA_COW_MAGIC 0xDEADBEEF
@@ -458,7 +459,8 @@ eina_cow_write(Eina_Cow *cow,
EAPI void
eina_cow_done(Eina_Cow *cow,
const Eina_Cow_Data * const * dst,
- const void *data)
+ const void *data,
+ Eina_Bool needed_gc)
{
Eina_Cow_Ptr *ref;
Eina_Cow_GC *gc;
@@ -477,6 +479,8 @@ eina_cow_done(Eina_Cow *cow,
ref->writing = EINA_FALSE;
#endif
+ if (!needed_gc) return ;
+
/* needed if we want to make cow gc safe */
if (ref->togc) return ;
diff --git a/src/lib/eina/eina_cow.h b/src/lib/eina/eina_cow.h
index 14414aaf72..c23da4968f 100644
--- a/src/lib/eina/eina_cow.h
+++ b/src/lib/eina/eina_cow.h
@@ -32,7 +32,8 @@ EAPI void *eina_cow_write(Eina_Cow *cow,
const Eina_Cow_Data * const *src) EINA_WARN_UNUSED_RESULT;
EAPI void eina_cow_done(Eina_Cow *cow,
const Eina_Cow_Data * const *dst,
- const void *data);
+ const void *data,
+ Eina_Bool needed_gc);
EAPI void eina_cow_memcpy(Eina_Cow *cow,
const Eina_Cow_Data * const *dst,
const Eina_Cow_Data *src);
@@ -47,7 +48,8 @@ EAPI Eina_Bool eina_cow_gc(Eina_Cow *cow);
Write = eina_cow_write(Cow, ((const Eina_Cow_Data**)&(Read)));
#define EINA_COW_WRITE_END(Cow, Read, Write) \
- eina_cow_done(Cow, ((const Eina_Cow_Data**)&(Read)), Write); \
+ eina_cow_done(Cow, ((const Eina_Cow_Data**)&(Read)), Write, \
+ EINA_TRUE); \
} \
while (0);
diff --git a/src/lib/evas/include/evas_private.h b/src/lib/evas/include/evas_private.h
index 3d0d21afe3..1d0def1555 100644
--- a/src/lib/evas/include/evas_private.h
+++ b/src/lib/evas/include/evas_private.h
@@ -1271,7 +1271,10 @@ extern Eina_Cow *evas_object_image_state_cow;
Evas_Object_Protected_State, Write)
# define EINA_COW_STATE_WRITE_END(Obj, Write, State) \
- EINA_COW_WRITE_END(evas_object_state_cow, Obj->State, Write)
+ eina_cow_done(evas_object_state_cow, ((const Eina_Cow_Data**)&(Obj->State)), \
+ Write, EINA_FALSE); \
+ } \
+ while (0);
/****************************************************************************/
/*****************************************/
diff --git a/src/tests/eina/eina_test_cow.c b/src/tests/eina/eina_test_cow.c
index cb50279ff9..e0c4ebc894 100644
--- a/src/tests/eina/eina_test_cow.c
+++ b/src/tests/eina/eina_test_cow.c
@@ -58,7 +58,7 @@ START_TEST(eina_cow_bad)
fail_if(write == NULL || write == &default_value);
write->i = 7;
- eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
+ eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write, EINA_FALSE);
fail_if(cur->i != 7 || default_value.i != 42);
#ifdef EINA_COW_MAGIC
@@ -67,7 +67,7 @@ START_TEST(eina_cow_bad)
eina_log_print_cb_set(_eina_test_log, &over_commit);
/* Testing over commit */
- eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
+ eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write, EINA_FALSE);
fail_if(!over_commit);
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
@@ -106,7 +106,7 @@ START_TEST(eina_cow)
fail_if(write == NULL || write == &default_value);
write->i = 7;
- eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
+ eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write, EINA_TRUE);
fail_if(cur->i != 7 || prev->i != 0);
eina_cow_memcpy(cow,
@@ -119,7 +119,7 @@ START_TEST(eina_cow)
fail_if(write == NULL || write == &default_value);
write->i = 42; write->c = 5;
- eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
+ eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write, EINA_TRUE);
fail_if(cur->i != 42 || cur->c != 5 ||
prev->i != 7 || prev->c != 42 ||
default_value.c != 42 || default_value.i != 0);
@@ -129,7 +129,7 @@ START_TEST(eina_cow)
write = eina_cow_write(cow, (const Eina_Cow_Data**) &cur);
write->i = 7; write->c = 42;
- eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write);
+ eina_cow_done(cow, (const Eina_Cow_Data**) &cur, write, EINA_TRUE);
fail_if(eina_cow_gc(cow) == EINA_FALSE);
fail_if(cur != prev);