From patchwork Tue Sep 23 17:54:37 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Wilco X-Patchwork-Id: 392610 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 47B5614007D for ; Wed, 24 Sep 2014 03:54:48 +1000 (EST) DomainKey-Signature: a=rsa-sha1; c=nofws; d=sourceware.org; h=list-id :list-unsubscribe:list-subscribe:list-archive:list-post :list-help:sender:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; q=dns; s=default; b=lR6 SDcjgc8l7qQP2jJASHJfNc+6nPcozE2nbPt7X5T1H64yitozt7FRN+lMqsoFaz9i 2WtruOqkTbGX85DmFXU3f6widH3Vef/PBGsONQ2QZLiT+2bv5nG1DV3ZkJfGBfvn 20fr0Ie0HAgKtRAOKQiSC6d4G2lDEci7Y2/DJxXk= 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:from:to:subject:date:message-id:mime-version :content-type:content-transfer-encoding; s=default; bh=uoHl2JB+f ZxdNyZNIUU1Nnjv9/M=; b=ZM9Jpt4ZCFPaXslpfCCiwuYuFUY7Bk+NrIpfDu6C8 THcHbVfd7kQSh/YM7jgassU7gowJfCtvdNWO1qQyZ/5QRWa2oY30KiPIEQu5N/v1 0D8ebKc1UxAI3oo1c5Wj9p1hsQ/zNReGsKhxN1jMwgH9Bn/TwAmmem42Qzu/scOX BM= Received: (qmail 19783 invoked by alias); 23 Sep 2014 17:54:43 -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 19772 invoked by uid 89); 23 Sep 2014 17:54:42 -0000 Authentication-Results: sourceware.org; auth=none X-Virus-Found: No X-Spam-SWARE-Status: No, score=-2.0 required=5.0 tests=AWL, BAYES_00, SPF_PASS autolearn=ham version=3.3.2 X-HELO: service87.mimecast.com From: "Wilco Dijkstra" To: Subject: [PATCH] Improve performance of strcpy Date: Tue, 23 Sep 2014 18:54:37 +0100 Message-ID: <000201cfd757$718a9d70$549fd850$@com> MIME-Version: 1.0 X-MC-Unique: 114092318543802101 Hi, Similar to previous patches, this patch improves strcpy performance by using strlen+memcpy. This is significantly faster than a simple byte-loop, on bench-strcpy speedup is > 2x. ChangeLog: 2014-09-23 Wilco Dijkstra * string/strcpy.c (strcpy): Improve performance by using strlen and memcpy. --- string/strcpy.c | 13 +------------ 1 file changed, 1 insertion(+), 12 deletions(-) diff --git a/string/strcpy.c b/string/strcpy.c index caa234a..91f9cc6 100644 --- a/string/strcpy.c +++ b/string/strcpy.c @@ -24,17 +24,6 @@ char * strcpy (char *dest, const char *src) { - char c; - char *s = (char *) src; - const ptrdiff_t off = dest - s - 1; - - do - { - c = *s++; - s[off] = c; - } - while (c != '\0'); - - return dest; + return memcpy (dest, src, strlen (src) + 1)); } libc_hidden_builtin_def (strcpy)