[Rd] Unneeded if statements in RealFromComplex C code

Hervé Pagès hp@ge@@on@g|thub @end|ng |rom gm@||@com
Fri Sep 10 02:54:06 CEST 2021


I just stumbled across these 2 lines in RealFromComplex (lines 208 & 209 
in src/main/coerce.c):

   double attribute_hidden

   RealFromComplex(Rcomplex x, int *warn)


       if (ISNAN(x.r) || ISNAN(x.i))

           return NA_REAL;

       if (ISNAN(x.r)) return x.r;
               <- line 208
       if (ISNAN(x.i)) return NA_REAL;
           <- line 209
       if (x.i != 0)

           *warn |= WARN_IMAG;

       return x.r;


They were added in 2015 (revision 69410).

They don't serve any purpose and might slow things down a little (unless 
compiler optimization is able to ignore them). In any case they should 
probably be removed.


Hervé Pagès

Bioconductor Core Team
hpages.on.github using gmail.com

More information about the R-devel mailing list