From 743e2047636ee7deb8dca87afd8651aa0c83bffb Mon Sep 17 00:00:00 2001 From: Jean-Philippe Andre Date: Thu, 22 Aug 2013 16:53:51 +0900 Subject: [PATCH] evas/cserve2: Optimize shared strings Shared string indexes are not repacked, since they live in a memory pool (where the indexes can be reused). So, the index in the table is equal to their ID. Add initial test to check if the item at index n has the ID n. --- src/bin/evas/evas_cserve2_index.c | 8 ++++++++ src/bin/evas/evas_cserve2_shm_debug.c | 8 ++++++++ src/lib/evas/cserve2/evas_cs2_client.c | 8 ++++++++ 3 files changed, 24 insertions(+) diff --git a/src/bin/evas/evas_cserve2_index.c b/src/bin/evas/evas_cserve2_index.c index 699ef95064..816a686d23 100644 --- a/src/bin/evas/evas_cserve2_index.c +++ b/src/bin/evas/evas_cserve2_index.c @@ -544,6 +544,14 @@ _shared_index_entry_get_by_id(Shared_Index *si, unsigned int id) base = si->sa->ds->data + sizeof(Shared_Array_Header); elemsize = si->sa->header->elemsize; + // Direct access, works for non-repacked arrays + if ((int) id < high) + { + obj = (Index_Entry *) (base + (elemsize * id)); + if (obj->id == id) + return obj; + } + // Binary search start_high = high; while(high != low) diff --git a/src/bin/evas/evas_cserve2_shm_debug.c b/src/bin/evas/evas_cserve2_shm_debug.c index e17e5d2b40..bde62bd89b 100644 --- a/src/bin/evas/evas_cserve2_shm_debug.c +++ b/src/bin/evas/evas_cserve2_shm_debug.c @@ -286,6 +286,14 @@ _shared_index_item_get_by_id(Shm_File *si, int elemsize, unsigned int id) base = si->data + sizeof(Shared_Array_Header); + // Direct access, works for non-repacked arrays + if ((int) id < high) + { + obj = (Shm_Object *) (base + (elemsize * id)); + if (obj->id == id) + return obj; + } + // Binary search start_high = high; while(high != low) diff --git a/src/lib/evas/cserve2/evas_cs2_client.c b/src/lib/evas/cserve2/evas_cs2_client.c index 5721d0bd69..9bcf966339 100644 --- a/src/lib/evas/cserve2/evas_cs2_client.c +++ b/src/lib/evas/cserve2/evas_cs2_client.c @@ -1929,6 +1929,14 @@ _shared_index_item_get_by_id(Shared_Index *si, int elemsize, unsigned int id) base = si->data + sizeof(Shared_Array_Header); + // Direct access, works for non-repacked arrays + if ((int) id < high) + { + obj = (Shm_Object *) (base + (elemsize * id)); + if (obj->id == id) + return obj; + } + // Binary search start_high = high; while(high != low)