Movatterモバイル変換


[0]ホーム

URL:


Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit0209f02

Browse files
committed
Don't use is_infinite() where isinf() will do.
Places that aren't testing for sign should not use the more expensivefunction; it's just wasteful, not to mention being a cognitive loadfor readers who may know what isinf() is but not is_infinite().As things stand, we actually don't need is_infinite() anyplace exceptfloat4out/float8out, which means it could potentially go away altogetherafter the changes I proposed in <13178.1538794717@sss.pgh.pa.us>.
1 parent07ee62c commit0209f02

File tree

2 files changed

+10
-8
lines changed

2 files changed

+10
-8
lines changed

‎src/backend/utils/adt/formatting.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5731,7 +5731,7 @@ float4_to_char(PG_FUNCTION_ARGS)
57315731
numstr=orgnum=int_to_roman((int)rint(value));
57325732
elseif (IS_EEEE(&Num))
57335733
{
5734-
if (isnan(value)||is_infinite(value))
5734+
if (isnan(value)||isinf(value))
57355735
{
57365736
/*
57375737
* Allow 6 characters for the leading sign, the decimal point,
@@ -5835,7 +5835,7 @@ float8_to_char(PG_FUNCTION_ARGS)
58355835
numstr=orgnum=int_to_roman((int)rint(value));
58365836
elseif (IS_EEEE(&Num))
58375837
{
5838-
if (isnan(value)||is_infinite(value))
5838+
if (isnan(value)||isinf(value))
58395839
{
58405840
/*
58415841
* Allow 6 characters for the leading sign, the decimal point,

‎src/backend/utils/adt/rangetypes_selfuncs.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,8 @@
1717
*/
1818
#include"postgres.h"
1919

20+
#include<math.h>
21+
2022
#include"access/htup_details.h"
2123
#include"catalog/pg_operator.h"
2224
#include"catalog/pg_statistic.h"
@@ -750,27 +752,27 @@ get_position(TypeCacheEntry *typcache, RangeBound *value, RangeBound *hist1,
750752
staticdouble
751753
get_len_position(doublevalue,doublehist1,doublehist2)
752754
{
753-
if (!is_infinite(hist1)&& !is_infinite(hist2))
755+
if (!isinf(hist1)&& !isinf(hist2))
754756
{
755757
/*
756758
* Both bounds are finite. The value should be finite too, because it
757759
* lies somewhere between the bounds. If it doesn't, just return
758760
* something.
759761
*/
760-
if (is_infinite(value))
762+
if (isinf(value))
761763
return0.5;
762764

763765
return1.0- (hist2-value) / (hist2-hist1);
764766
}
765-
elseif (is_infinite(hist1)&& !is_infinite(hist2))
767+
elseif (isinf(hist1)&& !isinf(hist2))
766768
{
767769
/*
768770
* Lower bin boundary is -infinite, upper is finite. Return 1.0 to
769771
* indicate the value is infinitely far from the lower bound.
770772
*/
771773
return1.0;
772774
}
773-
elseif (is_infinite(hist1)&&is_infinite(hist2))
775+
elseif (isinf(hist1)&&isinf(hist2))
774776
{
775777
/* same as above, but in reverse */
776778
return0.0;
@@ -851,7 +853,7 @@ calc_length_hist_frac(Datum *length_hist_values, int length_hist_nvalues,
851853
return0.0;/* shouldn't happen, but doesn't hurt to check */
852854

853855
/* All lengths in the table are <= infinite. */
854-
if (is_infinite(length2)&&equal)
856+
if (isinf(length2)&&equal)
855857
return1.0;
856858

857859
/*----------
@@ -978,7 +980,7 @@ calc_length_hist_frac(Datum *length_hist_values, int length_hist_nvalues,
978980
* length2 is infinite. It's not clear what the correct value would be in
979981
* that case, so 0.5 seems as good as any value.
980982
*/
981-
if (is_infinite(area)&&is_infinite(length2))
983+
if (isinf(area)&&isinf(length2))
982984
frac=0.5;
983985
else
984986
frac=area / (length2-length1);

0 commit comments

Comments
 (0)

[8]ページ先頭

©2009-2025 Movatter.jp