Skip to content

Commit b11eb36

Browse files
committed
MDEV-11451: isinf || isnan -> !isfinite
There are only 3 logical states for a number. The isfinite is a single function call rather than multiple leaving scope for compiler /architecture optimization. Changed the logic as follows in a few files. my_isinf(square) || my_isnan(square) -> !isfinite(square) Signed-off-by: Daniel Black <daniel.black@au.ibm.com>
1 parent dc9f919 commit b11eb36

File tree

4 files changed

+7
-6
lines changed

4 files changed

+7
-6
lines changed

sql/item_strfunc.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2671,7 +2671,7 @@ String *Item_func_format::val_str_ascii(String *str)
26712671
return 0; /* purecov: inspected */
26722672
nr= my_double_round(nr, (longlong) dec, FALSE, FALSE);
26732673
str->set_real(nr, dec, &my_charset_numeric);
2674-
if (isnan(nr) || my_isinf(nr))
2674+
if (!isfinite(nr))
26752675
return str;
26762676
str_length=str->length();
26772677
}

storage/innobase/gis/gis0geo.cc

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -364,8 +364,9 @@ mbr_join_square(
364364
b += 2;
365365
} while (a != end);
366366

367-
/* Check for infinity or NaN, so we don't get NaN in calculations */
368-
if (my_isinf(square) || my_isnan(square)) {
367+
/* Check if finite (not infinity or NaN),
368+
so we don't get NaN in calculations */
369+
if (!isfinite(square)) {
369370
return DBL_MAX;
370371
}
371372

storage/innobase/gis/gis0rtree.cc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1988,7 +1988,7 @@ rtr_estimate_n_rows_in_range(
19881988
mtr_commit(&mtr);
19891989
mem_heap_free(heap);
19901990

1991-
if (my_isinf(area) || my_isnan(area)) {
1991+
if (!isfinite(area)) {
19921992
return(HA_POS_ERROR);
19931993
}
19941994

storage/myisam/rt_split.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -69,8 +69,8 @@ static double mbr_join_square(const double *a, const double *b, int n_dim)
6969
b += 2;
7070
}while (a != end);
7171

72-
/* Check for infinity or NaN */
73-
if (my_isinf(square) || isnan(square))
72+
/* Check if not finite (i.e. infinity or NaN) */
73+
if (!isfinite(square))
7474
square = DBL_MAX;
7575

7676
return square;

0 commit comments

Comments
 (0)