Use bit tricks for HB_DIRECTION_IS_*
We already depend on the exact values of the direction enum in HB_DIRECTION_REVERSE(), so we may as well use that.
This commit is contained in:
parent
22da7fd94d
commit
1ce4dc95db
|
@ -79,10 +79,10 @@ typedef enum _hb_direction_t {
|
||||||
HB_DIRECTION_BTT
|
HB_DIRECTION_BTT
|
||||||
} hb_direction_t;
|
} hb_direction_t;
|
||||||
|
|
||||||
#define HB_DIRECTION_IS_HORIZONTAL(dir) ((dir) == HB_DIRECTION_LTR || (dir) == HB_DIRECTION_RTL)
|
#define HB_DIRECTION_IS_HORIZONTAL(dir) ((((unsigned int) (dir)) & ~1U) == 0)
|
||||||
#define HB_DIRECTION_IS_VERTICAL(dir) ((dir) == HB_DIRECTION_TTB || (dir) == HB_DIRECTION_BTT)
|
#define HB_DIRECTION_IS_VERTICAL(dir) ((((unsigned int) (dir)) & ~1U) == 2)
|
||||||
#define HB_DIRECTION_IS_FORWARD(dir) ((dir) == HB_DIRECTION_LTR || (dir) == HB_DIRECTION_TTB)
|
#define HB_DIRECTION_IS_FORWARD(dir) ((((unsigned int) (dir)) & ~2U) == 0)
|
||||||
#define HB_DIRECTION_IS_BACKWARD(dir) ((dir) == HB_DIRECTION_RTL || (dir) == HB_DIRECTION_BTT)
|
#define HB_DIRECTION_IS_BACKWARD(dir) ((((unsigned int) (dir)) & ~2U) == 1)
|
||||||
#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1))
|
#define HB_DIRECTION_REVERSE(dir) ((hb_direction_t) (((unsigned int) (dir)) ^ 1))
|
||||||
|
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue