Re: src/port/snprintf.c: Optimize the common base=10 case in fmtint

From: Andres Freund <andres(at)anarazel(dot)de>
To: Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us>
Cc: Mark Dilger <mark(dot)dilger(at)enterprisedb(dot)com>, Arjan van de Ven <arjan(at)linux(dot)intel(dot)com>, pgsql-hackers(at)postgresql(dot)org
Subject: Re: src/port/snprintf.c: Optimize the common base=10 case in fmtint
Date: 2021-10-26 18:58:31
Message-ID: 20211026185831.2r4bdyoojzpgu5gg@alap3.anarazel.de
Views: Raw Message | Whole Thread | Download mbox | Resend email
Thread:
Lists: pgsql-hackers

Hi,

On 2021-10-26 14:33:08 -0400, Tom Lane wrote:
> Andres Freund <andres(at)anarazel(dot)de> writes:
> > On 2021-10-26 13:51:55 -0400, Tom Lane wrote:
> >> I'd be inclined to just hard-wire the three allowed cases, and not have
> >> an arbitrary-divisor code path at all.
>
> > Yea, I came to the same conclusion. But I'd implement it by moving the
> > division into a separate inline function called from the switch. I tested that
> > locally and it works, but I got sidetracked by [1].
>
> Uh, why not just a "switch (base)" around three copies of the loop?
> Don't overthink this.

Well, putting the loop into its own function isn't really much more
complicated than duplicating the body. And there's also a few more
"unnecessarily run-time" branches that we could get rid of that way.

But I'm also ok with duplicating, at least for now.

Greetings,

Andres Freund

In response to

Browse pgsql-hackers by date

  From Date Subject
Next Message Jonathan S. Katz 2021-10-26 18:59:19 allowing "map" for password auth methods with clientcert=verify-full
Previous Message Andrew Dunstan 2021-10-26 18:50:49 Re: CREATEROLE and role ownership hierarchies