🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: comp.lang.c.moderated
Article #2165

Re: Readability

#2165
From: Graham Coles
Date: Mon, 04 Mar 1996 04:15
28 lines
1531 bytes
In article <4fcq34$fik@solutions.solon.com>, Colin McMahon
<engstad@funcom.no> writes
>Michael Smith (msmith@mpx.com.au) wrote:
>:      while (*src) *(dest++) = *(src++);
>
>Why don't you use: memcpy(dest, src, strlen(src))? On about all Intel 
>80x86 machines (I think Pentiums actually are faster without it), this 
>function is inlined to compile as a fast REP MOVSW.

Two reasons:

1. Other platforms don't necessarily have this type of instruction.

2. Using the above may seriously slow the code down.

Consider copying a "string" on a UNIX system which is 200 Kb in size.
You then have to:

 (a)  process 200K of characters to find the length of the string, then
 (b)  copy 200K from one buffer to another.

This is inevitably going to be slower as the original code only performs
one copy!


--
Graham Coles           |      e-mail: graham@scitec.demon.co.uk
Sci-Tec Software       |      flames: bill@microsoft.com     :)
Technical Details
Message-ID: <4hdqpl$8tr@solutions.solon.com>
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
References: <4dj2hq$l9e@solutions.solon.com> <4e5oad$664@solutions.solon.com> <4e7tik$pm@solutions.solon.com> <4e9ets$99q@solutions.solon.com>

Show Full Headers
Complete Article Headers
Path: arc1-ca.pugleaf.net!solon.com!not-for-mail
From: Graham Coles <graham@scitec.demon.co.uk>
Newsgroups: comp.lang.c.moderated
Subject: Re: Readability
Date: 3 Mar 1996 22:15:49 -0600
Organization: Sci-Tec Software
Sender: clc@solutions.solon.com
Approved: clc@solutions.solon.com
Message-ID: <4hdqpl$8tr@solutions.solon.com>
References: <4dj2hq$l9e@solutions.solon.com> <4e5oad$664@solutions.solon.com>
 <4e7tik$pm@solutions.solon.com> <4e9ets$99q@solutions.solon.com>
NNTP-Posting-Host: solutions.solon.com
X-Newsreader: Turnpike Version 1.10 <z5W0tcVhqGfVfh2lSJpSSlkSb1>