Enlightenment CVS committal
Author : raster
Project : e17
Module : libs/evas
Dir : e17/libs/evas/src/lib/data
Modified Files:
evas_stringshare.c
Log Message:
less overhead per string for stringshare (overhead right now is 2 pointers, 1
int (ie 12 bytes on 32bit, 20 bytes on 64bit systems). this removes 2 ptrs of
overhead (8 or 16 bytes) compared to before.
===================================================================
RCS file: /cvsroot/enlightenment/e17/libs/evas/src/lib/data/evas_stringshare.c,v
retrieving revision 1.1
retrieving revision 1.2
diff -u -3 -r1.1 -r1.2
--- evas_stringshare.c 28 Nov 2005 15:18:00 -0000 1.1
+++ evas_stringshare.c 29 Nov 2005 03:01:56 -0000 1.2
@@ -11,9 +11,8 @@
struct _Evas_Stringshare_El
{
- Evas_Object_List _list_data;
- char *str;
- int references;
+ int references;
+ Evas_Stringshare_El *next, *prev;
};
static inline int _evas_stringshare_hash_gen(const char *str);
@@ -59,55 +58,69 @@
evas_stringshare_add(const char *str)
{
int hash_num;
+ char *el_str;
Evas_Stringshare_El *el;
- Evas_Object_List *l;
hash_num = _evas_stringshare_hash_gen(str);
- for (l = share.buckets[hash_num]; l; l = l->next)
+ for (el = share.buckets[hash_num]; el; el = el->next)
{
- el = (Evas_Stringshare_El *)l;
- if (!strcmp(el->str, str))
+ el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
+ if (!strcmp(el_str, str))
{
- if (l != share.buckets[hash_num])
+ if (el->prev)
{
- share.buckets[hash_num] =
evas_object_list_remove(share.buckets[hash_num], el);
- share.buckets[hash_num] =
evas_object_list_prepend(share.buckets[hash_num], el);
+ el->prev->next = el->next;
+ if (el->next) el->next->prev = el->prev;
+ el->prev = NULL;
+ el->next = share.buckets[hash_num];
+ share.buckets[hash_num] = el;
}
el->references++;
- return el->str;
+ return el_str;
}
}
- if (!(el = malloc(sizeof(struct _Evas_Stringshare_El) + strlen(str) + 1)))
return NULL;
- el->str = ((unsigned char *)el) + sizeof(struct _Evas_Stringshare_El);
- strcpy(el->str, str);
+ if (!(el = malloc(sizeof(Evas_Stringshare_El) + strlen(str) + 1))) return
NULL;
+ el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
+ strcpy(el_str, str);
el->references = 1;
- share.buckets[hash_num] = evas_object_list_prepend(share.buckets[hash_num],
el);
- return el->str;
+ el->prev = NULL;
+ el->next = share.buckets[hash_num];
+ share.buckets[hash_num] = el;
+ return el_str;
}
void
evas_stringshare_del(const char *str)
{
int hash_num;
+ char *el_str;
Evas_Stringshare_El *el;
- Evas_Object_List *l;
hash_num = _evas_stringshare_hash_gen(str);
- for (l = share.buckets[hash_num]; l; l = l->next)
+ for (el = share.buckets[hash_num]; el; el = el->next)
{
- el = (Evas_Stringshare_El *)l;
- if (!strcmp(el->str, str))
+ el_str = ((char *)el) + sizeof(Evas_Stringshare_El);
+ if (!strcmp(el_str, str))
{
el->references--;
if (el->references == 0)
{
+ if (el->next) el->next->prev = el->prev;
+ if (el->prev) el->prev->next = el->next;
+ else share.buckets[hash_num] = el->next;
share.buckets[hash_num] =
evas_object_list_remove(share.buckets[hash_num], el);
free(el);
}
else
{
- share.buckets[hash_num] =
evas_object_list_remove(share.buckets[hash_num], el);
- share.buckets[hash_num] =
evas_object_list_prepend(share.buckets[hash_num], el);
+ if (el->prev)
+ {
+ el->prev->next = el->next;
+ if (el->next) el->next->prev = el->prev;
+ el->prev = NULL;
+ el->next = share.buckets[hash_num];
+ share.buckets[hash_num] = el;
+ }
}
return;
}
-------------------------------------------------------
This SF.net email is sponsored by: Splunk Inc. Do you grep through log files
for problems? Stop! Download the new AJAX search engine that makes
searching your log files as easy as surfing the web. DOWNLOAD SPLUNK!
http://ads.osdn.com/?ad_id=7637&alloc_id=16865&op=click
_______________________________________________
enlightenment-cvs mailing list
[email protected]
https://lists.sourceforge.net/lists/listinfo/enlightenment-cvs