forked from enlightenment/efl
eet: remove use of prev to reduce memory usage (30KB on 32bits system).
This commit is contained in:
parent
f001cfac38
commit
5465eb3acc
|
@ -32,7 +32,6 @@ struct _Eet_String
|
||||||
int len;
|
int len;
|
||||||
|
|
||||||
int next;
|
int next;
|
||||||
int prev;
|
|
||||||
};
|
};
|
||||||
struct _Eet_Dictionary
|
struct _Eet_Dictionary
|
||||||
{
|
{
|
||||||
|
|
|
@ -52,7 +52,8 @@ static int
|
||||||
_eet_dictionary_lookup(Eet_Dictionary *ed,
|
_eet_dictionary_lookup(Eet_Dictionary *ed,
|
||||||
const char *string,
|
const char *string,
|
||||||
int len,
|
int len,
|
||||||
int hash)
|
int hash,
|
||||||
|
int *previous)
|
||||||
{
|
{
|
||||||
Eina_Bool found = EINA_FALSE;
|
Eina_Bool found = EINA_FALSE;
|
||||||
int prev = -1;
|
int prev = -1;
|
||||||
|
@ -78,8 +79,14 @@ _eet_dictionary_lookup(Eet_Dictionary *ed,
|
||||||
}
|
}
|
||||||
|
|
||||||
if ((current == -1) && found)
|
if ((current == -1) && found)
|
||||||
return prev;
|
{
|
||||||
|
// WTF ?!? How can current == -1 and found == EINA_TRUE
|
||||||
|
// If you happen to trigger this abort, contact enlightenment developer mailing list
|
||||||
|
abort();
|
||||||
|
return prev;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (previous) *previous = prev;
|
||||||
return current;
|
return current;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -91,6 +98,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
|
||||||
const char *str;
|
const char *str;
|
||||||
int hash;
|
int hash;
|
||||||
int idx;
|
int idx;
|
||||||
|
int pidx;
|
||||||
int len;
|
int len;
|
||||||
int cnt;
|
int cnt;
|
||||||
|
|
||||||
|
@ -102,7 +110,7 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
|
||||||
|
|
||||||
eina_lock_take(&ed->mutex);
|
eina_lock_take(&ed->mutex);
|
||||||
|
|
||||||
idx = _eet_dictionary_lookup(ed, string, len, hash);
|
idx = _eet_dictionary_lookup(ed, string, len, hash, &pidx);
|
||||||
|
|
||||||
if (idx != -1)
|
if (idx != -1)
|
||||||
{
|
{
|
||||||
|
@ -153,19 +161,14 @@ eet_dictionary_string_add(Eet_Dictionary *ed,
|
||||||
if (idx == -1)
|
if (idx == -1)
|
||||||
{
|
{
|
||||||
current->next = ed->hash[hash];
|
current->next = ed->hash[hash];
|
||||||
current->prev = -1;
|
|
||||||
ed->hash[hash] = ed->count;
|
ed->hash[hash] = ed->count;
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
current->next = idx;
|
current->next = idx;
|
||||||
current->prev = ed->all[idx].prev;
|
|
||||||
|
|
||||||
if (current->next != -1)
|
if (pidx != -1)
|
||||||
ed->all[current->next].prev = ed->count;
|
ed->all[pidx].next = ed->count;
|
||||||
|
|
||||||
if (current->prev != -1)
|
|
||||||
ed->all[current->prev].next = ed->count;
|
|
||||||
else
|
else
|
||||||
ed->hash[hash] = ed->count;
|
ed->hash[hash] = ed->count;
|
||||||
}
|
}
|
||||||
|
|
|
@ -445,11 +445,16 @@ eet_flush2(Eet_File *ef)
|
||||||
for (j = 0; j < ef->ed->count; ++j)
|
for (j = 0; j < ef->ed->count; ++j)
|
||||||
{
|
{
|
||||||
int sbuf[EET_FILE2_DICTIONARY_ENTRY_COUNT];
|
int sbuf[EET_FILE2_DICTIONARY_ENTRY_COUNT];
|
||||||
|
int prev = 0;
|
||||||
|
|
||||||
|
// We still use the prev as an hint for knowing if it is the head of the hash
|
||||||
|
if (ef->ed->hash[ef->ed->all_hash[j]] == j)
|
||||||
|
prev = -1;
|
||||||
|
|
||||||
sbuf[0] = (int)htonl((unsigned int)ef->ed->all_hash[j]);
|
sbuf[0] = (int)htonl((unsigned int)ef->ed->all_hash[j]);
|
||||||
sbuf[1] = (int)htonl((unsigned int)offset);
|
sbuf[1] = (int)htonl((unsigned int)offset);
|
||||||
sbuf[2] = (int)htonl((unsigned int)ef->ed->all[j].len);
|
sbuf[2] = (int)htonl((unsigned int)ef->ed->all[j].len);
|
||||||
sbuf[3] = (int)htonl((unsigned int)ef->ed->all[j].prev);
|
sbuf[3] = (int)htonl((unsigned int)prev);
|
||||||
sbuf[4] = (int)htonl((unsigned int)ef->ed->all[j].next);
|
sbuf[4] = (int)htonl((unsigned int)ef->ed->all[j].next);
|
||||||
|
|
||||||
offset += ef->ed->all[j].len;
|
offset += ef->ed->all[j].len;
|
||||||
|
@ -959,12 +964,13 @@ eet_internal_read2(Eet_File *ef)
|
||||||
for (j = 0; j < ef->ed->count; ++j)
|
for (j = 0; j < ef->ed->count; ++j)
|
||||||
{
|
{
|
||||||
unsigned int offset;
|
unsigned int offset;
|
||||||
|
int prev;
|
||||||
int hash;
|
int hash;
|
||||||
|
|
||||||
GET_INT(hash, dico, idx);
|
GET_INT(hash, dico, idx);
|
||||||
GET_INT(offset, dico, idx);
|
GET_INT(offset, dico, idx);
|
||||||
GET_INT(ef->ed->all[j].len, dico, idx);
|
GET_INT(ef->ed->all[j].len, dico, idx);
|
||||||
GET_INT(ef->ed->all[j].prev, dico, idx);
|
GET_INT(prev, dico, idx); // Let's ignore prev link for dictionary, use it only as an hint to head
|
||||||
GET_INT(ef->ed->all[j].next, dico, idx);
|
GET_INT(ef->ed->all[j].next, dico, idx);
|
||||||
|
|
||||||
/* Hash value could be stored on 8bits data, but this will break alignment of all the others data.
|
/* Hash value could be stored on 8bits data, but this will break alignment of all the others data.
|
||||||
|
@ -992,7 +998,7 @@ eet_internal_read2(Eet_File *ef)
|
||||||
return NULL;
|
return NULL;
|
||||||
|
|
||||||
ef->ed->all_hash[j] = hash;
|
ef->ed->all_hash[j] = hash;
|
||||||
if (ef->ed->all[j].prev == -1)
|
if (prev == -1)
|
||||||
ef->ed->hash[hash] = j;
|
ef->ed->hash[hash] = j;
|
||||||
|
|
||||||
/* compute the possible position of a signature */
|
/* compute the possible position of a signature */
|
||||||
|
|
Loading…
Reference in New Issue