mirror of
https://git.postgresql.org/git/postgresql.git
synced 2024-09-30 21:01:20 +02:00
Don't use is_infinite() where isinf() will do.
Places that aren't testing for sign should not use the more expensive function; it's just wasteful, not to mention being a cognitive load for readers who may know what isinf() is but not is_infinite(). As things stand, we actually don't need is_infinite() anyplace except float4out/float8out, which means it could potentially go away altogether after the changes I proposed in <13178.1538794717@sss.pgh.pa.us>.
This commit is contained in:
parent
07ee62ce9e
commit
0209f0285d
@ -5731,7 +5731,7 @@ float4_to_char(PG_FUNCTION_ARGS)
|
|||||||
numstr = orgnum = int_to_roman((int) rint(value));
|
numstr = orgnum = int_to_roman((int) rint(value));
|
||||||
else if (IS_EEEE(&Num))
|
else if (IS_EEEE(&Num))
|
||||||
{
|
{
|
||||||
if (isnan(value) || is_infinite(value))
|
if (isnan(value) || isinf(value))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Allow 6 characters for the leading sign, the decimal point,
|
* Allow 6 characters for the leading sign, the decimal point,
|
||||||
@ -5835,7 +5835,7 @@ float8_to_char(PG_FUNCTION_ARGS)
|
|||||||
numstr = orgnum = int_to_roman((int) rint(value));
|
numstr = orgnum = int_to_roman((int) rint(value));
|
||||||
else if (IS_EEEE(&Num))
|
else if (IS_EEEE(&Num))
|
||||||
{
|
{
|
||||||
if (isnan(value) || is_infinite(value))
|
if (isnan(value) || isinf(value))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Allow 6 characters for the leading sign, the decimal point,
|
* Allow 6 characters for the leading sign, the decimal point,
|
||||||
|
@ -17,6 +17,8 @@
|
|||||||
*/
|
*/
|
||||||
#include "postgres.h"
|
#include "postgres.h"
|
||||||
|
|
||||||
|
#include <math.h>
|
||||||
|
|
||||||
#include "access/htup_details.h"
|
#include "access/htup_details.h"
|
||||||
#include "catalog/pg_operator.h"
|
#include "catalog/pg_operator.h"
|
||||||
#include "catalog/pg_statistic.h"
|
#include "catalog/pg_statistic.h"
|
||||||
@ -750,19 +752,19 @@ get_position(TypeCacheEntry *typcache, RangeBound *value, RangeBound *hist1,
|
|||||||
static double
|
static double
|
||||||
get_len_position(double value, double hist1, double hist2)
|
get_len_position(double value, double hist1, double hist2)
|
||||||
{
|
{
|
||||||
if (!is_infinite(hist1) && !is_infinite(hist2))
|
if (!isinf(hist1) && !isinf(hist2))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Both bounds are finite. The value should be finite too, because it
|
* Both bounds are finite. The value should be finite too, because it
|
||||||
* lies somewhere between the bounds. If it doesn't, just return
|
* lies somewhere between the bounds. If it doesn't, just return
|
||||||
* something.
|
* something.
|
||||||
*/
|
*/
|
||||||
if (is_infinite(value))
|
if (isinf(value))
|
||||||
return 0.5;
|
return 0.5;
|
||||||
|
|
||||||
return 1.0 - (hist2 - value) / (hist2 - hist1);
|
return 1.0 - (hist2 - value) / (hist2 - hist1);
|
||||||
}
|
}
|
||||||
else if (is_infinite(hist1) && !is_infinite(hist2))
|
else if (isinf(hist1) && !isinf(hist2))
|
||||||
{
|
{
|
||||||
/*
|
/*
|
||||||
* Lower bin boundary is -infinite, upper is finite. Return 1.0 to
|
* Lower bin boundary is -infinite, upper is finite. Return 1.0 to
|
||||||
@ -770,7 +772,7 @@ get_len_position(double value, double hist1, double hist2)
|
|||||||
*/
|
*/
|
||||||
return 1.0;
|
return 1.0;
|
||||||
}
|
}
|
||||||
else if (is_infinite(hist1) && is_infinite(hist2))
|
else if (isinf(hist1) && isinf(hist2))
|
||||||
{
|
{
|
||||||
/* same as above, but in reverse */
|
/* same as above, but in reverse */
|
||||||
return 0.0;
|
return 0.0;
|
||||||
@ -851,7 +853,7 @@ calc_length_hist_frac(Datum *length_hist_values, int length_hist_nvalues,
|
|||||||
return 0.0; /* shouldn't happen, but doesn't hurt to check */
|
return 0.0; /* shouldn't happen, but doesn't hurt to check */
|
||||||
|
|
||||||
/* All lengths in the table are <= infinite. */
|
/* All lengths in the table are <= infinite. */
|
||||||
if (is_infinite(length2) && equal)
|
if (isinf(length2) && equal)
|
||||||
return 1.0;
|
return 1.0;
|
||||||
|
|
||||||
/*----------
|
/*----------
|
||||||
@ -978,7 +980,7 @@ calc_length_hist_frac(Datum *length_hist_values, int length_hist_nvalues,
|
|||||||
* length2 is infinite. It's not clear what the correct value would be in
|
* length2 is infinite. It's not clear what the correct value would be in
|
||||||
* that case, so 0.5 seems as good as any value.
|
* that case, so 0.5 seems as good as any value.
|
||||||
*/
|
*/
|
||||||
if (is_infinite(area) && is_infinite(length2))
|
if (isinf(area) && isinf(length2))
|
||||||
frac = 0.5;
|
frac = 0.5;
|
||||||
else
|
else
|
||||||
frac = area / (length2 - length1);
|
frac = area / (length2 - length1);
|
||||||
|
Loading…
Reference in New Issue
Block a user