mailing list of musl libc
 help / color / mirror / code / Atom feed
From: Rich Felker <dalias@libc.org>
To: musl@lists.openwall.com
Subject: Re: Non-stub gettext API functions committed, ready for testing
Date: Mon, 28 Jul 2014 12:27:32 -0400	[thread overview]
Message-ID: <20140728162731.GD1674@brightrain.aerifal.cx> (raw)
In-Reply-To: <20140728140151.GL10402@port70.net>

On Mon, Jul 28, 2014 at 04:01:52PM +0200, Szabolcs Nagy wrote:
> * Szabolcs Nagy <nsz@port70.net> [2014-07-28 15:00:17 +0200]:
> > * Szabolcs Nagy <nsz@port70.net> [2014-07-28 12:18:30 +0200]:
> > > the parser and eval code is about 2k now, i can try to do it
> > > without a separate parsing step (my approach requires a 100-200
> > > byte buffer to store the parsed expr now)
> > > 
> > 
> > attached a simpler solution without separate parsing
> > (code is about 1.4k now, and it is more compatible
> > with gnu gettext)
> > 
> 
> using a complex plural expression (arabic):
> 
> "(n==0 ? 0 : n==1 ? 1 : n==2 ? 2 : n%100>=3 && n%100<=10 ? 3 : n%100>=11 ? 4 : 5);"
> 
> the runtime of my preparsed vs interpreted implementation is
> 0.1-0.5us vs 3us testing on a few small n.

My leaning is to go with the version that's smaller and more flexible;
I think the time spent in this function will usually be heavily
dominated by the binary search for the message text. But it's cool to
have both for possible future uses (independent of musl, even).

BTW one way to reduce the cost is to skip the whole plural computation
when msgid1==msgid2 (as pointers). This is always true when dcngettext
is called by one of the "non-n" gettext functions.

Rich


  reply	other threads:[~2014-07-28 16:27 UTC|newest]

Thread overview: 14+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2014-07-27  8:46 Rich Felker
2014-07-27 10:06 ` Harald Becker
2014-07-27 14:14   ` Szabolcs Nagy
2014-07-27 16:49     ` Rich Felker
2014-07-27 17:23       ` Szabolcs Nagy
2014-07-27 17:36         ` Rich Felker
2014-07-27 17:51           ` Szabolcs Nagy
2014-07-27 18:00             ` Rich Felker
2014-07-28 10:18               ` Szabolcs Nagy
2014-07-28 13:00                 ` Szabolcs Nagy
2014-07-28 14:01                   ` Szabolcs Nagy
2014-07-28 16:27                     ` Rich Felker [this message]
2014-07-29 13:49                       ` Szabolcs Nagy
2014-07-27 10:19 ` Harald Becker

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=20140728162731.GD1674@brightrain.aerifal.cx \
    --to=dalias@libc.org \
    --cc=musl@lists.openwall.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).