From patchwork Sun May 24 15:40:17 2015 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: =?utf-8?b?T25kxZllaiBCw61sa2E=?= X-Patchwork-Id: 475981 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Received: from sourceware.org (server1.sourceware.org [209.132.180.131]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id A311A14016A for ; Mon, 25 May 2015 01:40:42 +1000 (AEST) Authentication-Results: ozlabs.org; dkim=pass (1024-bit key; unprotected) header.d=sourceware.org header.i=@sourceware.org header.b=Srv9rBpm; dkim-atps=neutral DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; q=dns; s=default; b=W761 yVjq+ycUaHF14PAbw4aoYBTcXNtkrXlQKJL1cF9pTpq+CoblTWOslH9e3wRFBhgf YeRR3UZgyiWIUXQxO2z0vMOyBaQUuZznnwsSUhidIKFdpG8twema9lf2Xav1RrSE nSbBhpjXT6BeCI4yIHg8Bl6AXnUIjlVnxwuVhZ8= DKIM-Signature: v=1; a=rsa-sha1; c=relaxed; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:date:from:to:subject:message-id:references :mime-version:content-type:in-reply-to; s=default; bh=LrMpRPUEGw rmjUApx4+u+xlLU5I=; b=Srv9rBpmFQVwkynbSZD6TooYk309VWhP3tYWPA6nWu KhFpaRProF5GQ/OSD5K9/FdX6hZRT/ZYepR8dvhURXPUGEllukG3yIO5rRw7LgAC mQz607O7C8ysQkVKX24ByfNbify4kVY5GTTwrXpv2xb03bWI6c5YHVPMnwTZfSw4 o= Received: (qmail 71449 invoked by alias); 24 May 2015 15:40:36 -0000 Mailing-List: contact libc-alpha-help@sourceware.org; run by ezmlm Precedence: bulk List-Id: List-Unsubscribe: List-Subscribe: List-Archive: List-Post: List-Help: , Sender: libc-alpha-owner@sourceware.org Delivered-To: mailing list libc-alpha@sourceware.org Received: (qmail 71431 invoked by uid 89); 24 May 2015 15:40:36 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-0.7 required=5.0 tests=AWL, BAYES_00, FREEMAIL_FROM, SPF_NEUTRAL autolearn=no version=3.3.2 X-HELO: popelka.ms.mff.cuni.cz Date: Sun, 24 May 2015 17:40:17 +0200 From: =?utf-8?B?T25kxZllaiBCw61sa2E=?= To: libc-alpha@sourceware.org Subject: Re: [PATCH 3/*] Use strchrnul for strcspn (x, "c") Message-ID: <20150524154017.GA18976@domone> References: <20150524150715.GA31589@domone> MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20150524150715.GA31589@domone> User-Agent: Mutt/1.5.20 (2009-06-14) A loop there is clearly suboptimal. We improve performance by using strchrnul equivalent. OK to commit? * string/bits/string2.h (__strcspn_c1): Optimize with __strchrnul. diff --git a/string/bits/string2.h b/string/bits/string2.h index a595c74..2fe67b3 100644 --- a/string/bits/string2.h +++ b/string/bits/string2.h @@ -277,10 +277,7 @@ __STRING_INLINE size_t __strcspn_c1 (const char *__s, int __reject); __STRING_INLINE size_t __strcspn_c1 (const char *__s, int __reject) { - size_t __result = 0; - while (__s[__result] != '\0' && __s[__result] != __reject) - ++__result; - return __result; + return __strchrnul (__s, __reject) - __s; } __STRING_INLINE size_t __strcspn_c2 (const char *__s, int __reject1,