--- rxvt-unicode/src/rxvtutil.h 2007/12/02 22:37:14 1.34 +++ rxvt-unicode/src/rxvtutil.h 2008/07/21 16:51:31 1.37 @@ -15,10 +15,18 @@ #if __GNUC__ >= 4 # define rxvt_attribute(x) __attribute__(x) +# define expect(expr,value) __builtin_expect ((expr),(value)) #else # define rxvt_attribute(x) +# define expect(expr,value) (expr) #endif +// put into ifs if you are very sure that the expression +// is mostly true or mosty false. note that these return +// booleans, not the expression. +#define expect_false(expr) expect ((expr) != 0, 0) +#define expect_true(expr) expect ((expr) != 0, 1) + #define NORETURN rxvt_attribute ((noreturn)) #define UNUSED rxvt_attribute ((unused)) #define CONST rxvt_attribute ((const)) @@ -101,6 +109,9 @@ #define IN_RANGE_EXC(val,beg,end) \ ((unsigned int)(val) - (unsigned int)(beg) < (unsigned int)(end) - (unsigned int)(beg)) +// for m >= -n, ensure remainder lies between 0..n-1 +#define MOD(m,n) (((m) + (n)) % (n)) + // makes dynamically allocated objects zero-initialised struct zero_initialized { void *operator new (size_t s); @@ -364,7 +375,8 @@ template struct vector : simplevec -{ }; +{ +}; struct stringvec : simplevec {