forked from openGauss-Ecosystem/openGauss-server
优化numeric var初始化的性能
This commit is contained in:
parent
55a8dc30ed
commit
d4a2ea2050
|
@ -75,7 +75,8 @@
|
|||
* otherwise, we want the long one. Instead of testing against each value, we
|
||||
* can just look at the high bit, for a slight efficiency gain.
|
||||
*/
|
||||
#define NUMERIC_HEADER_SIZE(n) (VARHDRSZ + sizeof(uint16) + (((NUMERIC_FLAGBITS(n) & 0x8000) == 0) ? sizeof(int16) : 0))
|
||||
#define NUMERIC_HEADER_IS_SHORT(n) (((n)->choice.n_header & 0x8000) != 0)
|
||||
#define NUMERIC_HEADER_SIZE(n) (VARHDRSZ + sizeof(uint16) + (NUMERIC_HEADER_IS_SHORT(n) ? 0 : sizeof(int16)))
|
||||
|
||||
/*
|
||||
* Short format definitions.
|
||||
|
@ -95,17 +96,17 @@
|
|||
#define NUMERIC_DSCALE_MASK 0x3FFF
|
||||
|
||||
#define NUMERIC_SIGN(n) \
|
||||
(NUMERIC_IS_SHORT(n) ? (((n)->choice.n_short.n_header & NUMERIC_SHORT_SIGN_MASK) ? NUMERIC_NEG : NUMERIC_POS) \
|
||||
(NUMERIC_HEADER_IS_SHORT(n) ? (((n)->choice.n_short.n_header & NUMERIC_SHORT_SIGN_MASK) ? NUMERIC_NEG : NUMERIC_POS) \
|
||||
: NUMERIC_FLAGBITS(n))
|
||||
#define NUMERIC_DSCALE(n) \
|
||||
(NUMERIC_IS_SHORT((n)) ? ((n)->choice.n_short.n_header & NUMERIC_SHORT_DSCALE_MASK) >> NUMERIC_SHORT_DSCALE_SHIFT \
|
||||
(NUMERIC_HEADER_IS_SHORT((n)) ? ((n)->choice.n_short.n_header & NUMERIC_SHORT_DSCALE_MASK) >> NUMERIC_SHORT_DSCALE_SHIFT \
|
||||
: ((n)->choice.n_long.n_sign_dscale & NUMERIC_DSCALE_MASK))
|
||||
#define NUMERIC_WEIGHT(n) \
|
||||
(NUMERIC_IS_SHORT((n)) \
|
||||
(NUMERIC_HEADER_IS_SHORT((n)) \
|
||||
? (((n)->choice.n_short.n_header & NUMERIC_SHORT_WEIGHT_SIGN_MASK ? ~NUMERIC_SHORT_WEIGHT_MASK : 0) | \
|
||||
((n)->choice.n_short.n_header & NUMERIC_SHORT_WEIGHT_MASK)) \
|
||||
: ((n)->choice.n_long.n_weight))
|
||||
#define NUMERIC_DIGITS(num) (NUMERIC_IS_SHORT(num) ? (num)->choice.n_short.n_data : (num)->choice.n_long.n_data)
|
||||
#define NUMERIC_DIGITS(num) (NUMERIC_HEADER_IS_SHORT(num) ? (num)->choice.n_short.n_data : (num)->choice.n_long.n_data)
|
||||
#define NUMERIC_NDIGITS(num) ((VARSIZE(num) - NUMERIC_HEADER_SIZE(num)) / sizeof(NumericDigit))
|
||||
|
||||
/*
|
||||
|
|
Loading…
Reference in New Issue