Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 28 May 1996 08:29:15 +0200
From:      "Philippe Charnier" <charnier@lirmm.fr>
To:        hackers@freebsd.org
Subject:   strcpy, strcat: not the same look & feel.
Message-ID:  <199605280629.IAA09104@lirmm.lirmm.fr>

next in thread | raw e-mail | index | archive | help
Hi,

Which one is faster, the old version or the one with this patch applied?
Libc uses another one (assembler) but this could at least make libkern
faster. Or is it even better to use the libc's version? I'm not really sure
about my results but it seems that the following patch make strcpy 8% faster
(-O0) 6% faster (-O) and 0% faster (-O2) on my i486 according to gprof.

--- strcpy.c	1994/05/27 04:57:55	1.1.1.1
+++ strcpy.c	1996/05/25 21:33:23
@@ -35,7 +35,6 @@
 static char sccsid[] = "@(#)strcpy.c	8.1 (Berkeley) 6/4/93";
 #endif /* LIBC_SCCS and not lint */

-#include <sys/cdefs.h>
 #include <string.h>

 char *
@@ -45,6 +44,6 @@
 {
	char *save = to;

-	for (; *to = *from; ++from, ++to);
+	while (*to++ = *from++);
	return(save);
 }

--------                                                        --------
Philippe Charnier                                      charnier@lirmm.fr
                               

         LIRMM, 161 rue Ada, 34392 Montpellier cedex 5 -- France
------------------------------------------------------------------------




Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?199605280629.IAA09104>