From owner-freebsd-chat Tue May 28 14:12:00 1996 Return-Path: owner-chat Received: (from root@localhost) by freefall.freebsd.org (8.7.5/8.7.3) id OAA29798 for chat-outgoing; Tue, 28 May 1996 14:12:00 -0700 (PDT) Received: from eac.iafrica.com (h196-7-192-158.iafrica.com [196.7.192.158]) by freefall.freebsd.org (8.7.5/8.7.3) with SMTP id OAA29785 for ; Tue, 28 May 1996 14:11:53 -0700 (PDT) Received: (from rnordier@localhost) by eac.iafrica.com (8.6.12/8.6.12) id XAA00428; Tue, 28 May 1996 23:08:26 +0200 From: Robert Nordier Message-Id: <199605282108.XAA00428@eac.iafrica.com> Subject: Re: strcpy, strcat: not the same look & feel. To: terry@lambert.org (Terry Lambert) Date: Tue, 28 May 1996 23:08:25 +0200 (SAT) Cc: chat@freebsd.org In-Reply-To: <199605281805.LAA11436@phaeton.artisoft.com> from "Terry Lambert" at May 28, 96 11:05:39 am X-Mailer: ELM [version 2.4 PL24 ME8a] Content-Type: text Sender: owner-chat@freebsd.org X-Loop: FreeBSD.org Precedence: bulk Terry Lambert wrote: > There is also some conventional wisdom on pre vs. post-incrementing, > which I wasn't going to mention because I was under the impresson > that all modern compilers dealt with it. > > Post-increment is generally faster if you have the instruction set for > it; not all systems have the instruction set. This is interesting, and made me recall some old x86 stuff which makes the opposite claim. The context is different, of course, so it doesn't really contradict Terry. Pre-increment/decrement operators are often more efficient than the post-increment/decrement version. This is valid mostly when these operators are combined in the expressions using compares (like ++i), and has no effect if the simple ++i; or i; is done (without a compare). The reason for this is that the processor flags are changed by ++ or, thus the (i++ N) must generate an extra code (usually a JMP) to prevent ++ from destroying the result of the compare. -- RT This is a great piece of technical explanation, and anyone who wants to score points in -hackers can learn a lot from it: Keep your examples inline, limited to 4 characters or less, and get them mostly wrong. :) RT "designed and coded the world's first MS-DOS based multi-user, multi-processor operating system." (Though, to be fair, RT probably just had a lousy copy editor.) Any guesses what extra code the statement i++ N would generate, if not a JMP? -- Robert Nordier