forked from enlightenment/efl
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.
This commit is contained in:
parent
71fdd0d342
commit
743e204763
|
@ -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);
|
base = si->sa->ds->data + sizeof(Shared_Array_Header);
|
||||||
elemsize = si->sa->header->elemsize;
|
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
|
// Binary search
|
||||||
start_high = high;
|
start_high = high;
|
||||||
while(high != low)
|
while(high != low)
|
||||||
|
|
|
@ -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);
|
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
|
// Binary search
|
||||||
start_high = high;
|
start_high = high;
|
||||||
while(high != low)
|
while(high != low)
|
||||||
|
|
|
@ -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);
|
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
|
// Binary search
|
||||||
start_high = high;
|
start_high = high;
|
||||||
while(high != low)
|
while(high != low)
|
||||||
|
|
Loading…
Reference in New Issue