pg.ddx.io  pgsql-committers@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Dean Rasheed <dean.a.rasheed@gmail.com>
To: pgsql-committers@lists.postgresql.org
Subject: pgsql: Simplify the inner loop of numeric division in div_var().
Date: Sun, 27 Feb 2022 10:42:48 +0000
Message-ID: <E1nOH0p-00086N-JS@gemulon.postgresql.org> (raw)

Simplify the inner loop of numeric division in div_var().

In the standard numeric division algorithm, the inner loop multiplies
the divisor by the next quotient digit and subtracts that from the
working dividend. As suggested by the original code comment, the
separate "carry" and "borrow" variables (from the multiplication and
subtraction steps respectively) can be folded together into a single
variable. Doing so significantly improves performance, as well as
simplifying the code.

Dean Rasheed, reviewed by Tom Lane.

Discussion: https://postgr.es/m/CAEZATCVwsBi-ND-t82Cuuh1=8ee6jdOpzsmGN+CUZB6yjLg9jw@mail.gmail.com

Branch
------
master

Details
-------
https://git.postgresql.org/pg/commitdiff/d996d648f333b04ae3da3c5853120f6f37601fb2

Modified Files
--------------
src/backend/utils/adt/numeric.c | 36 +++++++++++++++---------------------
1 file changed, 15 insertions(+), 21 deletions(-)



Message-ID: <E1nOH0p-00086N-JS@gemulon.postgresql.org>
Permalink:  ../E1nOH0p-00086N-JS@gemulon.postgresql.org/
Also on:    postgresql.org/message-id/E1nOH0p-00086N-JS@gemulon.postgresql.org

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-committers@postgresql.org
  Cc: dean.a.rasheed@gmail.com
  Subject: Re: pgsql: Simplify the inner loop of numeric division in div_var().
  In-Reply-To: <E1nOH0p-00086N-JS@gemulon.postgresql.org>
  References: <E1nOH0p-00086N-JS@gemulon.postgresql.org>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox