Browse Source

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>
pull/263/head
Daniel Black 9 years ago
parent
commit
b11eb36963
  1. 2
      sql/item_strfunc.cc
  2. 5
      storage/innobase/gis/gis0geo.cc
  3. 2
      storage/innobase/gis/gis0rtree.cc
  4. 4
      storage/myisam/rt_split.c

2
sql/item_strfunc.cc

@ -2671,7 +2671,7 @@ String *Item_func_format::val_str_ascii(String *str)
return 0; /* purecov: inspected */
nr= my_double_round(nr, (longlong) dec, FALSE, FALSE);
str->set_real(nr, dec, &my_charset_numeric);
if (isnan(nr) || my_isinf(nr))
if (!isfinite(nr))
return str;
str_length=str->length();
}

5
storage/innobase/gis/gis0geo.cc

@ -364,8 +364,9 @@ mbr_join_square(
b += 2;
} while (a != end);
/* Check for infinity or NaN, so we don't get NaN in calculations */
if (my_isinf(square) || my_isnan(square)) {
/* Check if finite (not infinity or NaN),
so we don't get NaN in calculations */
if (!isfinite(square)) {
return DBL_MAX;
}

2
storage/innobase/gis/gis0rtree.cc

@ -1988,7 +1988,7 @@ rtr_estimate_n_rows_in_range(
mtr_commit(&mtr);
mem_heap_free(heap);
if (my_isinf(area) || my_isnan(area)) {
if (!isfinite(area)) {
return(HA_POS_ERROR);
}

4
storage/myisam/rt_split.c

@ -69,8 +69,8 @@ static double mbr_join_square(const double *a, const double *b, int n_dim)
b += 2;
}while (a != end);
/* Check for infinity or NaN */
if (my_isinf(square) || isnan(square))
/* Check if not finite (i.e. infinity or NaN) */
if (!isfinite(square))
square = DBL_MAX;
return square;

Loading…
Cancel
Save