Branch: Tag:


2013-06-12 15:46:03 by Per Hedbor <>

[performance] Significantly faster is_lt and svalue_is_true

The is_lt function now uses no stack at all, which speeds it up about
a factor of ten (for the case where both arguments are integers).

Much the same was done for svalue_is_true.

Also, the order of the tests were rearrenged to get some other

Interrestingly enough is_lt is actually faster even for the complex
cases now, for whatever reason gcc seems to generate better code.

360:   /* SAFE_IS_ZERO is compatible with the old IS_ZERO, but you should    * consider using UNSAFE_IS_ZERO instead, since exceptions thrown from    * `! functions will be propagated correctly then. */ - #define UNSAFE_IS_ZERO(X) (TYPEOF(*(X))==PIKE_T_INT?(X)->u.integer==0:(1<<TYPEOF(*(X)))&(BIT_OBJECT|BIT_FUNCTION)?!svalue_is_true(X):0) + #define UNSAFE_IS_ZERO(X) (TYPEOF(*(X))==PIKE_T_INT?(X)->u.integer==0:(1<<TYPEOF(*(X)))&(BIT_OBJECT|BIT_FUNCTION)?!complex_svalue_is_true(X):0)   #define SAFE_IS_ZERO(X) (TYPEOF(*(X))==PIKE_T_INT?(X)->u.integer==0:(1<<TYPEOF(*(X)))&(BIT_OBJECT|BIT_FUNCTION)?!safe_svalue_is_true(X):0)      #define IS_UNDEFINED(X) (check_svalue (X), TYPEOF(*(X))==PIKE_T_INT&&SUBTYPEOF(*(X))==NUMBER_UNDEFINED)
774:    const union anything *from,    TYPE_T type);   PMOD_EXPORT unsigned INT32 hash_svalue(const struct svalue *s); + PMOD_EXPORT int complex_svalue_is_true(const struct svalue *s); /* only handles object + function */   PMOD_EXPORT int svalue_is_true(const struct svalue *s);   PMOD_EXPORT int safe_svalue_is_true(const struct svalue *s);   PMOD_EXPORT int is_identical(const struct svalue *a, const struct svalue *b);