From owner-svn-src-stable@FreeBSD.ORG Sat Jul 12 17:39:14 2014 Return-Path: Delivered-To: svn-src-stable@freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [8.8.178.115]) (using TLSv1 with cipher ADH-AES256-SHA (256/256 bits)) (No client certificate requested) by hub.freebsd.org (Postfix) with ESMTPS id 59EF82D9; Sat, 12 Jul 2014 17:39:14 +0000 (UTC) Received: from svn.freebsd.org (svn.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 2BABC24B8; Sat, 12 Jul 2014 17:39:14 +0000 (UTC) Received: from svn.freebsd.org ([127.0.1.70]) by svn.freebsd.org (8.14.8/8.14.8) with ESMTP id s6CHdEwZ020335; Sat, 12 Jul 2014 17:39:14 GMT (envelope-from pfg@svn.freebsd.org) Received: (from pfg@localhost) by svn.freebsd.org (8.14.8/8.14.8/Submit) id s6CHdEkg020334; Sat, 12 Jul 2014 17:39:14 GMT (envelope-from pfg@svn.freebsd.org) Message-Id: <201407121739.s6CHdEkg020334@svn.freebsd.org> From: "Pedro F. Giffuni" Date: Sat, 12 Jul 2014 17:39:14 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-10@freebsd.org Subject: svn commit: r268571 - stable/10/lib/libc/locale X-SVN-Group: stable-10 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-stable@freebsd.org X-Mailman-Version: 2.1.18 Precedence: list List-Id: SVN commit messages for all the -stable branches of the src tree List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Sat, 12 Jul 2014 17:39:14 -0000 Author: pfg Date: Sat Jul 12 17:39:13 2014 New Revision: 268571 URL: http://svnweb.freebsd.org/changeset/base/268571 Log: MFC r268272: minor perf enhancement for UTF-8 Reduce some duplicate code. Reference: https://www.illumos.org/issues/628 Obtained from: Illumos Modified: stable/10/lib/libc/locale/utf8.c Directory Properties: stable/10/ (props changed) Modified: stable/10/lib/libc/locale/utf8.c ============================================================================== --- stable/10/lib/libc/locale/utf8.c Sat Jul 12 15:35:04 2014 (r268570) +++ stable/10/lib/libc/locale/utf8.c Sat Jul 12 17:39:13 2014 (r268571) @@ -1,4 +1,5 @@ /*- + * Copyright 2011 Nexenta Systems, Inc. All rights reserved. * Copyright (c) 2002-2004 Tim J. Robbins * All rights reserved. * @@ -112,13 +113,6 @@ _UTF8_mbrtowc(wchar_t * __restrict pwc, /* Incomplete multibyte sequence */ return ((size_t)-2); - if (us->want == 0 && ((ch = (unsigned char)*s) & ~0x7f) == 0) { - /* Fast path for plain ASCII characters. */ - if (pwc != NULL) - *pwc = ch; - return (ch != '\0' ? 1 : 0); - } - if (us->want == 0) { /* * Determine the number of octets that make up this character @@ -134,10 +128,12 @@ _UTF8_mbrtowc(wchar_t * __restrict pwc, */ ch = (unsigned char)*s; if ((ch & 0x80) == 0) { - mask = 0x7f; - want = 1; - lbound = 0; - } else if ((ch & 0xe0) == 0xc0) { + /* Fast path for plain ASCII characters. */ + if (pwc != NULL) + *pwc = ch; + return (ch != '\0' ? 1 : 0); + } + if ((ch & 0xe0) == 0xc0) { mask = 0x1f; want = 2; lbound = 0x80; @@ -316,12 +312,6 @@ _UTF8_wcrtomb(char * __restrict s, wchar /* Reset to initial shift state (no-op) */ return (1); - if ((wc & ~0x7f) == 0) { - /* Fast path for plain ASCII characters. */ - *s = (char)wc; - return (1); - } - /* * Determine the number of octets needed to represent this character. * We always output the shortest sequence possible. Also specify the @@ -329,8 +319,9 @@ _UTF8_wcrtomb(char * __restrict s, wchar * about the sequence length. */ if ((wc & ~0x7f) == 0) { - lead = 0; - len = 1; + /* Fast path for plain ASCII characters. */ + *s = (char)wc; + return (1); } else if ((wc & ~0x7ff) == 0) { lead = 0xc0; len = 2;