forked from enlightenment/efl
* eet: Reduce convertion to FP, float and double with a little overhead.
SVN revision: 44243
This commit is contained in:
parent
5dd7275c9a
commit
1a9212d3b0
|
@ -273,3 +273,4 @@
|
||||||
2009-12-07 Cedric BAIL
|
2009-12-07 Cedric BAIL
|
||||||
|
|
||||||
* Fix error when retrieving a different float type than the stored one.
|
* Fix error when retrieving a different float type than the stored one.
|
||||||
|
* Reduce convertion with a little memory overhead.
|
||||||
|
|
|
@ -11,10 +11,10 @@ typedef enum _Eet_Convert_Type Eet_Convert_Type;
|
||||||
|
|
||||||
enum _Eet_Convert_Type
|
enum _Eet_Convert_Type
|
||||||
{
|
{
|
||||||
EET_D_NOT_CONVERTED,
|
EET_D_NOT_CONVERTED = 0,
|
||||||
EET_D_FLOAT,
|
EET_D_FLOAT = 1 << 1,
|
||||||
EET_D_DOUBLE,
|
EET_D_DOUBLE = 1 << 2,
|
||||||
EET_D_FIXED_POINT
|
EET_D_FIXED_POINT = 1 << 4
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct _Eet_String Eet_String;
|
typedef struct _Eet_String Eet_String;
|
||||||
|
@ -30,12 +30,9 @@ struct _Eet_String
|
||||||
int next;
|
int next;
|
||||||
int prev;
|
int prev;
|
||||||
|
|
||||||
union
|
float f;
|
||||||
{
|
double d;
|
||||||
float f;
|
Eina_F32p32 fp;
|
||||||
double d;
|
|
||||||
Eina_F32p32 fp;
|
|
||||||
} convert;
|
|
||||||
|
|
||||||
Eet_Convert_Type type;
|
Eet_Convert_Type type;
|
||||||
};
|
};
|
||||||
|
|
|
@ -260,13 +260,13 @@ eet_dictionary_string_get_float(const Eet_Dictionary *ed, int index, float *resu
|
||||||
{
|
{
|
||||||
if (!_eet_dictionary_test(ed, index, result)) return EINA_FALSE;
|
if (!_eet_dictionary_test(ed, index, result)) return EINA_FALSE;
|
||||||
|
|
||||||
if (ed->all[index].type != EET_D_FLOAT)
|
if (!(ed->all[index].type & EET_D_FLOAT))
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
str = ed->all[index].str ? ed->all[index].str : ed->all[index].mmap;
|
str = ed->all[index].str ? ed->all[index].str : ed->all[index].mmap;
|
||||||
|
|
||||||
if (!_eet_dictionary_string_get_float_cache(str, ed->all[index].len, &ed->all[index].convert.f))
|
if (!_eet_dictionary_string_get_float_cache(str, ed->all[index].len, &ed->all[index].f))
|
||||||
{
|
{
|
||||||
long long mantisse = 0;
|
long long mantisse = 0;
|
||||||
long exponent = 0;
|
long exponent = 0;
|
||||||
|
@ -274,13 +274,13 @@ eet_dictionary_string_get_float(const Eet_Dictionary *ed, int index, float *resu
|
||||||
if (eina_convert_atod(str, ed->all[index].len, &mantisse, &exponent) == EINA_FALSE)
|
if (eina_convert_atod(str, ed->all[index].len, &mantisse, &exponent) == EINA_FALSE)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
ed->all[index].convert.f = ldexpf((float) mantisse, exponent);
|
ed->all[index].f = ldexpf((float) mantisse, exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
ed->all[index].type = EET_D_FLOAT;
|
ed->all[index].type |= EET_D_FLOAT;
|
||||||
}
|
}
|
||||||
|
|
||||||
*result = ed->all[index].convert.f;
|
*result = ed->all[index].f;
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -289,13 +289,13 @@ eet_dictionary_string_get_double(const Eet_Dictionary *ed, int index, double *re
|
||||||
{
|
{
|
||||||
if (!_eet_dictionary_test(ed, index, result)) return EINA_FALSE;
|
if (!_eet_dictionary_test(ed, index, result)) return EINA_FALSE;
|
||||||
|
|
||||||
if (ed->all[index].type != EET_D_DOUBLE)
|
if (!(ed->all[index].type & EET_D_DOUBLE))
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
|
|
||||||
str = ed->all[index].str ? ed->all[index].str : ed->all[index].mmap;
|
str = ed->all[index].str ? ed->all[index].str : ed->all[index].mmap;
|
||||||
|
|
||||||
if (!_eet_dictionary_string_get_double_cache(str, ed->all[index].len, &ed->all[index].convert.d))
|
if (!_eet_dictionary_string_get_double_cache(str, ed->all[index].len, &ed->all[index].d))
|
||||||
{
|
{
|
||||||
long long mantisse = 0;
|
long long mantisse = 0;
|
||||||
long exponent = 0;
|
long exponent = 0;
|
||||||
|
@ -303,13 +303,13 @@ eet_dictionary_string_get_double(const Eet_Dictionary *ed, int index, double *re
|
||||||
if (eina_convert_atod(str, ed->all[index].len, &mantisse, &exponent) == EINA_FALSE)
|
if (eina_convert_atod(str, ed->all[index].len, &mantisse, &exponent) == EINA_FALSE)
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
ed->all[index].convert.d = ldexp((double) mantisse, exponent);
|
ed->all[index].d = ldexp((double) mantisse, exponent);
|
||||||
}
|
}
|
||||||
|
|
||||||
ed->all[index].type = EET_D_DOUBLE;
|
ed->all[index].type |= EET_D_DOUBLE;
|
||||||
}
|
}
|
||||||
|
|
||||||
*result = ed->all[index].convert.d;
|
*result = ed->all[index].d;
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -318,7 +318,7 @@ eet_dictionary_string_get_fp(const Eet_Dictionary *ed, int index, Eina_F32p32 *r
|
||||||
{
|
{
|
||||||
if (!_eet_dictionary_test(ed, index, result)) return EINA_FALSE;
|
if (!_eet_dictionary_test(ed, index, result)) return EINA_FALSE;
|
||||||
|
|
||||||
if (ed->all[index].type != EET_D_FIXED_POINT)
|
if (!(ed->all[index].type & EET_D_FIXED_POINT))
|
||||||
{
|
{
|
||||||
const char *str;
|
const char *str;
|
||||||
Eina_F32p32 fp;
|
Eina_F32p32 fp;
|
||||||
|
@ -328,11 +328,11 @@ eet_dictionary_string_get_fp(const Eet_Dictionary *ed, int index, Eina_F32p32 *r
|
||||||
if (!eina_convert_atofp(str, ed->all[index].len, &fp))
|
if (!eina_convert_atofp(str, ed->all[index].len, &fp))
|
||||||
return EINA_FALSE;
|
return EINA_FALSE;
|
||||||
|
|
||||||
ed->all[index].convert.fp = fp;
|
ed->all[index].fp = fp;
|
||||||
ed->all[index].type = EET_D_FIXED_POINT;
|
ed->all[index].type |= EET_D_FIXED_POINT;
|
||||||
}
|
}
|
||||||
|
|
||||||
*result = ed->all[index].convert.fp;
|
*result = ed->all[index].fp;
|
||||||
return EINA_TRUE;
|
return EINA_TRUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue