From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from zimbra.cs.ucla.edu (zimbra.cs.ucla.edu [131.179.128.68]) by sourceware.org (Postfix) with ESMTPS id EA0943858C2D; Fri, 13 May 2022 05:28:48 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.1 sourceware.org EA0943858C2D Authentication-Results: sourceware.org; dmarc=none (p=none dis=none) header.from=cs.ucla.edu Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=cs.ucla.edu Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id 63A2316007E; Thu, 12 May 2022 22:28:48 -0700 (PDT) Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10032) with ESMTP id Y1_2M4V3XOfA; Thu, 12 May 2022 22:28:47 -0700 (PDT) Received: from localhost (localhost [127.0.0.1]) by zimbra.cs.ucla.edu (Postfix) with ESMTP id B5DBB160091; Thu, 12 May 2022 22:28:47 -0700 (PDT) X-Virus-Scanned: amavisd-new at zimbra.cs.ucla.edu Received: from zimbra.cs.ucla.edu ([127.0.0.1]) by localhost (zimbra.cs.ucla.edu [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id 4o4NTbTt2wtf; Thu, 12 May 2022 22:28:47 -0700 (PDT) Received: from [192.168.1.9] (cpe-172-91-119-151.socal.res.rr.com [172.91.119.151]) by zimbra.cs.ucla.edu (Postfix) with ESMTPSA id 87B3416007E; Thu, 12 May 2022 22:28:47 -0700 (PDT) Message-ID: Date: Thu, 12 May 2022 22:28:47 -0700 MIME-Version: 1.0 User-Agent: Mozilla/5.0 (X11; Linux x86_64; rv:91.0) Gecko/20100101 Thunderbird/91.8.1 Content-Language: en-US From: Paul Eggert To: Siddhesh Poyarekar Cc: fweimer@redhat.com, libc-alpha@sourceware.org, dickey@his.com References: <20220505184348.3357550-3-siddhesh@sourceware.org> <20220512131503.764504-1-siddhesh@sourceware.org> <4ffe566a-8002-b574-daee-d6927b8ceaef@cs.ucla.edu> Organization: UCLA Computer Science Department Subject: Re: [PATCH v3] wcrtomb: Make behavior POSIX compliant In-Reply-To: <4ffe566a-8002-b574-daee-d6927b8ceaef@cs.ucla.edu> Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 7bit X-Spam-Status: No, score=-4.8 required=5.0 tests=BAYES_00, KAM_DMARC_STATUS, NICE_REPLY_A, SPF_HELO_NONE, SPF_PASS, TXREP, T_SCC_BODY_TEXT_LINE autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org X-BeenThere: libc-alpha@sourceware.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: Libc-alpha mailing list List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 13 May 2022 05:28:50 -0000 On 5/12/22 21:56, Paul Eggert wrote: > Hope you don't mind my bikeshedding. Better yet, this: s[0] = buf[0]; if (2 <= result && result <= 4) { s[1] = buf[1]; memcpy (&s[result - 2], &buf[result - 2], 2); } else memcpy (s, buf, result); On x86-64 with GCC 12.1 -O2 and a glibc-supplied charmap, this is only 9 straight-line instructions, counting the compare insn and the conditional-branch insn that is never taken.