pgsql: Improve div_var_fast(), mostly by making comments better.

From: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
To: pgsql-committers(at)postgresql(dot)org
Subject: pgsql: Improve div_var_fast(), mostly by making comments better.
Date: 2015-11-25 21:06:02
Message-ID: E1a1hGM-0006iw-JN@gemulon.postgresql.org
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-committers

Improve div_var_fast(), mostly by making comments better.

The integer overflow situation in div_var_fast() is a great deal more
complicated than the pre-existing comments would suggest. Moreover, the
comments were also flat out incorrect as to the precise statement of the
maxdiv loop invariant. Upon clarifying that, it becomes apparent that the
way in which we updated maxdiv after a carry propagation pass was overly
slow, complex, and conservative: we can just reset it to one, which is much
easier and also reduces the number of times carry propagation occurs.
Fix that and improve the relevant comments.

Since this is mostly a comment fix, with only a rather marginal performance
boost, no need for back-patch.

Tom Lane and Dean Rasheed

Branch
------
master

Details
-------
http://git.postgresql.org/pg/commitdiff/46166197c3b3748c3266c694d7c2f5a312ea928e

Modified Files
--------------
src/backend/utils/adt/numeric.c | 64 +++++++++++++++++++++++++++++++--------
1 file changed, 52 insertions(+), 12 deletions(-)

Browse pgsql-committers by date

  From Date Subject
Next Message Tom Lane 2015-11-25 22:32:19 pgsql: Be more paranoid about null return values from libpq status func
Previous Message Teodor Sigaev 2015-11-25 14:00:13 Re: pgsql: Improve pageinspect module