mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: Viktor Reznov <yann.collet.is.not.a.perfectionist@gmail.com>
Cc: musl@lists.openwall.com
Subject: Re: [musl] [PATCH] Decreasing the number of divisions
Date: Tue, 16 Apr 2024 12:55:03 -0400	[thread overview]
Message-ID: <20240416165502.GL32430@brightrain.aerifal.cx> (raw)
In-Reply-To: <CAKs8_OKqKsLbG_Cf0DtDGeZDLdFkO1kDx6z5Fg_rQwPxPLGP6g@mail.gmail.com>

On Tue, Apr 16, 2024 at 07:34:32PM +0300, Viktor Reznov wrote:
> > Is there a reason you put the if at the top
> > rather than making the last line the following?
> 
> No.

Ok. Can I make that simplifying change and still attribute you as
commit author?

> On Tue, Apr 16, 2024 at 5:38 PM Rich Felker <dalias@libc.org> wrote:
> >
> > On Tue, Apr 16, 2024 at 04:29:05PM +0300, Viktor Reznov wrote:
> > > diff --git a/src/stdio/vfprintf.c b/src/stdio/vfprintf.c
> > > index 497c5e19..0f9a1e6a 100644
> > > --- a/src/stdio/vfprintf.c
> > > +++ b/src/stdio/vfprintf.c
> > > @@ -165,8 +165,10 @@ static char *fmt_o(uintmax_t x, char *s)
> > >  static char *fmt_u(uintmax_t x, char *s)
> > >  {
> > >         unsigned long y;
> > > +       if (x == 0) return s;
> > >         for (   ; x>ULONG_MAX; x/=10) *--s = '0' + x%10;
> > > -       for (y=x;           y; y/=10) *--s = '0' + y%10;
> > > +       for (y=x;       y>=10; y/=10) *--s = '0' + y%10;
> > > +       *--s = '0' + y;
> > >         return s;
> > >  }
> >
> > Seems like a good change. Is there a reason you put the if at the top
> > rather than making the last line the following?
> >
> >         if (y) *--s = '0' + y;
> >
> > That would keep the overall flow the same as before and avoid a burden
> > to reason about if/why it's the same.
> >
> > Rich

  parent reply	other threads:[~2024-04-16 16:54 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2024-04-16 13:29 Viktor Reznov
2024-04-16 14:29 ` Markus Wichmann
2024-04-17  1:25   ` NRK
2024-04-17  1:56     ` Markus Wichmann
2024-04-16 14:38 ` Rich Felker
     [not found]   ` <CAKs8_OKqKsLbG_Cf0DtDGeZDLdFkO1kDx6z5Fg_rQwPxPLGP6g@mail.gmail.com>
2024-04-16 16:55     ` Rich Felker [this message]
     [not found]       ` <CAKs8_OJ4evmTzAGVZ1Yccw+4Jj7v=RwEJWicwbSoeQwbvqav1Q@mail.gmail.com>
2024-04-17  0:09         ` [musl] " Rich Felker

Reply instructions:

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

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

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20240416165502.GL32430@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.com \
    --cc=yann.collet.is.not.a.perfectionist@gmail.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
Code repositories for project(s) associated with this public inbox

	https://git.vuxu.org/mirror/musl/

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).