From mboxrd@z Thu Jan 1 00:00:00 1970 X-Msuck: nntp://news.gmane.org/gmane.linux.lib.musl.general/11375 Path: news.gmane.org!.POSTED!not-for-mail From: "A. Wilcox" Newsgroups: gmane.linux.lib.musl.general Subject: Re: [PATCH] towupper/towlower: fast path for ascii chars Date: Tue, 30 May 2017 22:04:46 -0500 Organization: =?UTF-8?Q?Ad=c3=a9lie_Linux?= Message-ID: <592E32CE.3030908@adelielinux.org> References: <20170527005950.GA1627@brightrain.aerifal.cx> <20170530122324.23733-1-ncopa@alpinelinux.org> Reply-To: musl@lists.openwall.com NNTP-Posting-Host: blaine.gmane.org Mime-Version: 1.0 Content-Type: text/plain; charset=windows-1252 Content-Transfer-Encoding: 8bit X-Trace: blaine.gmane.org 1496199906 6778 195.159.176.226 (31 May 2017 03:05:06 GMT) X-Complaints-To: usenet@blaine.gmane.org NNTP-Posting-Date: Wed, 31 May 2017 03:05:06 +0000 (UTC) User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:38.0) Gecko/20100101 Thunderbird/38.5.0 To: musl@lists.openwall.com Original-X-From: musl-return-11388-gllmg-musl=m.gmane.org@lists.openwall.com Wed May 31 05:05:02 2017 Return-path: Envelope-to: gllmg-musl@m.gmane.org Original-Received: from mother.openwall.net ([195.42.179.200]) by blaine.gmane.org with smtp (Exim 4.84_2) (envelope-from ) id 1dFtwU-0001Yo-2p for gllmg-musl@m.gmane.org; Wed, 31 May 2017 05:05:02 +0200 Original-Received: (qmail 3225 invoked by uid 550); 31 May 2017 03:05:04 -0000 Mailing-List: contact musl-help@lists.openwall.com; run by ezmlm Precedence: bulk List-Post: List-Help: List-Unsubscribe: List-Subscribe: List-ID: Original-Received: (qmail 3198 invoked from network); 31 May 2017 03:05:03 -0000 In-Reply-To: <20170530122324.23733-1-ncopa@alpinelinux.org> Xref: news.gmane.org gmane.linux.lib.musl.general:11375 Archived-At: -----BEGIN PGP SIGNED MESSAGE----- Hash: SHA256 On 30/05/17 07:23, Natanael Copa wrote: > Make a fast path for ascii chars which is assumed to be the most > common case. This has significant performance benefit on xml json > and similar I'm not sure if that would be the common case when you are already dealing with wide chars. I would assume you're using wide chars for a reason... > { - return __towcase(wc, 0); + return (unsigned)wc < 128 ? > toupper(wc) : __towcase(wc, 0); } > > wint_t towlower(wint_t wc) { - return __towcase(wc, 1); + return > (unsigned)wc < 128 ? tolower(wc) : __towcase(wc, 1); } ...so I would likely do something like: return (unsigned)wc > 127 ? __towcase(wc, 1) : tolower(wc); I think it comes down to silly style though. Functionally it is likely similar / the same. Would be curious to see if there is any difference on other loads (and on other architectures). - --arw - -- A. Wilcox (awilfox) Project Lead, Adélie Linux http://adelielinux.org -----BEGIN PGP SIGNATURE----- Version: GnuPG v2 iQIcBAEBCAAGBQJZLjKRAAoJEMspy1GSK50UfPMQAI9WHwH2TRHfRBmC9F9dRRqR c0wTMC0IkaI9iD7xrdpG9lq6EhHelNbC94bIUFtHY5Eao4Vf6SJUv7b+o+OEHGs0 11PmDSvciHZx4vQb64rQJte8u6s3Z++POMpsLKULS4Gi63xLCtaCKB8yp4/eKezL 5cBqxCIXz+TlCpS/7TQxyYjwCA8C13Utd/2GmU4/9cCkdDOHJ5asg3sfFS4MtVPS tSSunDgDgn0b3b0nLD0q4PiymRZ0cpGj2MKLWCR2WPdBkMitjegNm4wYcJE6naWH ao4Fp26McviszvQvxlWzidpiDAq6kxU6jwHylV/VniseqcG5XBDDyG/MrzzMDlKr lyNGQg6xXAcVvIujZBJYJYrgL1oDEpQ6c+JS4aD4gcM0WIn8YM9K5PQPKbcwrsqo 2sDKY51UTT3SDoghtj7ZkqgBMbQLmEE5lyom3B7EtcQazKj9pWtTmCy8kI+cMQcT WPYurl67aEg54WW1oGChKza6P1WyuWTL27TL4NVOsVMyCqSa2ekF7rJTBP7rey9r hNuFz14/tKyZTA1Mq3RWtN15ydsC+ToLbZikYqEmmBq36p2J1BbeWznfRRw6dpyt G1sz70FtTBtODAK1xVngsUsYVPINgNhaQlQKs96NSiQzU0khY2or9kbYWPm0GyS8 fPerUQTvKecXmUYd2OVk =pfgv -----END PGP SIGNATURE-----