From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/5671 Path: news.gmane.org!not-for-mail From: Rich Felker Newsgroups: gmane.linux.lib.musl.general Subject: Re: Non-stub gettext API functions committed, ready for testing Date: Mon, 28 Jul 2014 12:27:32 -0400 Message-ID: <20140728162731.GD1674@brightrain.aerifal.cx> References: <53D4CF09.1050209@gmx.de> <20140727141417.GG10402@port70.net> <20140727164921.GY4038@brightrain.aerifal.cx> <20140727172308.GH10402@port70.net> <20140727173605.GZ4038@brightrain.aerifal.cx> <20140727175125.GI10402@port70.net> <20140727180041.GA4038@brightrain.aerifal.cx> <20140728101829.GJ10402@port70.net> <20140728130017.GK10402@port70.net> <20140728140151.GL10402@port70.net> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: plane.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii X-Trace: ger.gmane.org 1406564875 6066 80.91.229.3 (28 Jul 2014 16:27:55 GMT) X-Complaints-To: usenet@ger.gmane.org NNTP-Posting-Date: Mon, 28 Jul 2014 16:27:55 +0000 (UTC) To: musl@lists.openwall.com Original-X-From: musl-return-5676-gllmg-musl=m.gmane.org@lists.openwall.com Mon Jul 28 18:27:48 2014 Return-path: Envelope-to: gllmg-musl@plane.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by plane.gmane.org with smtp (Exim 4.69) (envelope-from ) id 1XBnm6-0002jb-9n for gllmg-musl@plane.gmane.org; Mon, 28 Jul 2014 18:27:46 +0200 Original-Received: (qmail 15901 invoked by uid 550); 28 Jul 2014 16:27:45 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: Original-Received: (qmail 15892 invoked from network); 28 Jul 2014 16:27:45 -0000 Content-Disposition: inline In-Reply-To: <20140728140151.GL10402@port70.net> User-Agent: Mutt/1.5.21 (2010-09-15) Original-Sender: Rich Felker Xref: news.gmane.org gmane.linux.lib.musl.general:5671 Archived-At: On Mon, Jul 28, 2014 at 04:01:52PM +0200, Szabolcs Nagy wrote: > * Szabolcs Nagy [2014-07-28 15:00:17 +0200]: > > * Szabolcs Nagy [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