From owner-freebsd-arch Sun Oct 31 15:49:44 1999 Delivered-To: freebsd-arch@freebsd.org Received: from ns1.yes.no (ns1.yes.no [195.204.136.10]) by hub.freebsd.org (Postfix) with ESMTP id 5985314F0E for ; Sun, 31 Oct 1999 15:49:32 -0800 (PST) (envelope-from eivind@bitbox.follo.net) Received: from bitbox.follo.net (bitbox.follo.net [195.204.143.218]) by ns1.yes.no (8.9.3/8.9.3) with ESMTP id AAA22740 for ; Mon, 1 Nov 1999 00:49:26 +0100 (CET) Received: (from eivind@localhost) by bitbox.follo.net (8.8.8/8.8.6) id AAA67967 for freebsd-arch@freebsd.org; Mon, 1 Nov 1999 00:49:26 +0100 (MET) Received: from arc.hq.cti.ru (arc.hq.cti.ru [195.34.40.3]) by hub.freebsd.org (Postfix) with ESMTP id A014814F0E for ; Sun, 31 Oct 1999 15:43:32 -0800 (PST) (envelope-from dima@tejblum.pp.ru) Received: (from uucp@localhost) by arc.hq.cti.ru (8.9.3/8.9.3) with UUCP id CAA10720; Mon, 1 Nov 1999 02:42:38 +0300 (MSK) (envelope-from dima@tejblum.pp.ru) Received: from tejblum.pp.ru (localhost [127.0.0.1]) by tejblum.pp.ru (8.9.3/8.9.3) with ESMTP id CAA02684; Mon, 1 Nov 1999 02:49:24 +0300 (MSK) (envelope-from dima@tejblum.pp.ru) Message-Id: <199910312349.CAA02684@tejblum.pp.ru> X-Mailer: exmh version 2.0gamma 1/27/96 To: obrien@NUXI.com Cc: Dmitrij Tejblum , freebsd-arch@freebsd.org From: Dmitrij Tejblum Subject: Re: stpcpy() In-reply-to: Your message of "Sun, 31 Oct 1999 14:50:49 PST." <19991031145049.A90745@dragon.nuxi.com> Mime-Version: 1.0 Content-Type: text/plain; charset=us-ascii Date: Mon, 01 Nov 1999 02:49:24 +0300 Sender: owner-freebsd-arch@FreeBSD.ORG Precedence: bulk X-Loop: FreeBSD.ORG "David O'Brien" wrote: > On Sun, Oct 31, 1999 at 02:07:26PM +1100, Bruce Evans wrote: > > > Good stpcpy() could double performance in some cases. You would touch a > > > symbol once where you previously touched it twice. > > > stpcpy() could halve performance in some cases (when the compiler inlines > > and combines strcpy() and strlen() but doesn't do anything special with > > stpcpy(), and inlining is good). > > Bruce hit the nail right on the head -- people are making assumptions > with out know what their compiler is doing. You omitted following Bruce's words: > > In practice, gcc seems to only inline strlen(). At any rate, sptcpy() can be slower only if we are stupid enough or the compiler is really ancient/braindamaged. If the compiler inlines and combines strcpy() and strlen(), we can implement stpcpy() as static __inline char * stpcpy(char *__to, const char *__from) { return (strcpy(__to, __from) + strlen(__from)); } in string.h and make the compiler perform all the optimizations. > > Also, strcpy() and strlen() could easily be highly optimized ASM routines > that together are still faster than a C stpcpy(). There is nothing that prevent to clone the highly optimized ASM strcpy() to create a highly optimized ASM stpcpy(). > > > > It actually may matter in some text-processing applications. > > Yes, BUT one should only use these non-standard functions AFTER they've > actually done some profiling and see where the program is REALLY spending > their time. Really? Why? My colleagues use Windows and occasionally use stpcpy(), just because it is CONVENIENT and obviously cannot make their program slower. If the program is slower on FreeBSD (or even not compile), this is not their fault. The convenience is the main reason to add stpcpy() into libc. After the "-v" option was added to mkdir, the antibloat arguments became utterly nonsense. Dima To Unsubscribe: send mail to majordomo@FreeBSD.org with "unsubscribe freebsd-arch" in the body of the message