Thread
Commits
-
Avoid unnecessary division in interval_cmp_value().
- e94c1a55dada 15.0 landed
-
Useless division(s) in interval_cmp_value
Tom Lane <tgl@sss.pgh.pa.us> — 2021-09-26T17:01:53Z
While thinking about Isaac Morland's patch to add abs(interval), I happened to notice that interval_cmp_value() seems rather inefficently written: it's expending an int64 division -- or even two of them, if the compiler's not very smart -- to split up the "time" field into days and microseconds. That's quite pointless, since we're immediately going to recombine the results into microseconds. Integer divisions are pretty expensive, too, on a lot of hardware. I suppose this is a hangover from when the code supported float as well as int64 time fields; but since that's long gone, I see no reason not to do the attached. regards, tom lane