mirror of
https://github.com/postgres/postgres.git
synced 2025-06-11 20:28:21 +03:00
Improve performance of float overflow checks in btree_gist
The current code could do unnecessary calls to isinf() (two for the
argument values all the time while one could be sufficient in some
cases). zero_is_valid was never used but the result value was still
checked on 0 in the first position of the check.
This is similar to 607f8ce
. btree_gist has just copy-pasted the code
doing those checks from the backend float4/8 code, as of the macro
CHECKFLOATVAL(), to do the work.
Author: Haiying Tang
Discussion: https://postgr.es/m/OS0PR01MB611358E3A7BC3C2F874AC36BFBF39@OS0PR01MB6113.jpnprd01.prod.outlook.com
This commit is contained in:
@ -5,6 +5,7 @@
|
||||
|
||||
#include "btree_gist.h"
|
||||
#include "btree_utils_num.h"
|
||||
#include "utils/float.h"
|
||||
|
||||
typedef struct float4key
|
||||
{
|
||||
@ -98,7 +99,8 @@ float4_dist(PG_FUNCTION_ARGS)
|
||||
float4 r;
|
||||
|
||||
r = a - b;
|
||||
CHECKFLOATVAL(r, isinf(a) || isinf(b), true);
|
||||
if (unlikely(isinf(r)) && !isinf(a) && !isinf(b))
|
||||
float_overflow_error();
|
||||
|
||||
PG_RETURN_FLOAT4(Abs(r));
|
||||
}
|
||||
|
Reference in New Issue
Block a user