From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail.ispras.ru (mail.ispras.ru [83.149.199.84]) by sourceware.org (Postfix) with ESMTPS id 31F973858CDA for ; Mon, 25 Sep 2023 06:45:34 +0000 (GMT) DMARC-Filter: OpenDMARC Filter v1.4.2 sourceware.org 31F973858CDA Authentication-Results: sourceware.org; dmarc=pass (p=none dis=none) header.from=ispras.ru Authentication-Results: sourceware.org; spf=pass smtp.mailfrom=ispras.ru Received: from [10.10.3.121] (unknown [10.10.3.121]) by mail.ispras.ru (Postfix) with ESMTPS id 6343E40F1DDF; Mon, 25 Sep 2023 06:45:32 +0000 (UTC) DKIM-Filter: OpenDKIM Filter v2.11.0 mail.ispras.ru 6343E40F1DDF Date: Mon, 25 Sep 2023 09:45:32 +0300 (MSK) From: Alexander Monakov To: Paul Eggert cc: Wilco Dijkstra , Xi Ruoyao , "tirtajames45@gmail.com" , 'GNU C Library' Subject: Re: [PATCH] ftw.c: Check for "." and ".." branchlessly In-Reply-To: Message-ID: <1d57ceb6-6d4d-430b-4522-082d138ce56c@ispras.ru> References: <940d2a96-fb7f-7fb2-87f3-0967f73b8205@cs.ucla.edu> MIME-Version: 1.0 Content-Type: text/plain; charset=US-ASCII X-Spam-Status: No, score=-3.1 required=5.0 tests=BAYES_00,KAM_DMARC_STATUS,SPF_HELO_NONE,SPF_PASS,TXREP autolearn=ham autolearn_force=no version=3.4.6 X-Spam-Checker-Version: SpamAssassin 3.4.6 (2021-04-09) on server2.sourceware.org List-Id: On Mon, 25 Sep 2023, Alexander Monakov wrote: > If you look at the context, you'll see that 'namlen' gives the length, so > > if (namlen < 3 && name[0] == '.' && name[namlen-1] == '.') > return 0; > > works, and you can combine that with shift-ors to a single comparison > (either relying on namlen to be always non-zero, or testing 'namlen-1 < 2') (together with replacing 'name[namlen-1]' with 'name[namlen/2]' for the latter) Alexander