Re: nitpick about useless floating point division in gimme_edge_table

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: Mark Dilger <hornschnorter(at)gmail(dot)com>
Cc: Pg Hackers <pgsql-hackers(at)postgresql(dot)org>
Subject: Re: nitpick about useless floating point division in gimme_edge_table
Date: 2019-05-23 16:50:53
Message-ID: 14936.1558630253@sss.pgh.pa.us
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Mark Dilger <hornschnorter(at)gmail(dot)com> writes:
> Hackers,
> The return value of gimme_edge_table is not used anywhere in the
> core code, so far as I can see. But the value is computed as

> /* return average number of edges per index */
> return ((float) (edge_total * 2) / (float) num_gene);

> which involves some floating point math. I'm not sure that this matters
> much, but (1) it deceives a reader of this code into thinking that this
> calculation is meaningful, which it is not, and (2) gimme_edge_table is
> called inside a loop, so this is happening repeatedly, though admittedly
> that loop is perhaps not terribly large.

Hmm, probably there was use for that once upon a time, but I agree it's
dead code now. Want to send a patch to change it to returns-void?

regards, tom lane

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Peter Eisentraut 2019-05-23 16:54:27 Re: initdb recommendations
Previous Message Tom Lane 2019-05-23 16:48:49 Re: Is it safe to ignore the return value of SPI_finish and SPI_execute?