cvs.gedasymbols.org/archives/browse.cgi   search  
Mail Archives: djgpp/1999/11/16/14:26:52

From: alainm AT news DOT RISQ DOT QC DOT CA (Alain Magloire)
Subject: Re: strset function
Newsgroups: comp.os.msdos.djgpp
References: <1e1batd DOT 137nbir1xiefqN AT d249 DOT paris-48 DOT cybercable DOT fr> <19b54f3c DOT 0c6b504d AT usw-ex0103-019 DOT remarq DOT com> <lNVX3.1117$0c2 DOT 30770 AT carnaval DOT risq DOT qc DOT ca> <80pep1$nmb AT acp3bf DOT knirsch DOT de>
X-Newsreader: TIN [version 1.2 PL2]
Lines: 36
Message-ID: <b9fY3.1764$0c2.44477@carnaval.risq.qc.ca>
Date: Tue, 16 Nov 1999 15:56:55 GMT
NNTP-Posting-Host: 132.206.63.174
X-Complaints-To: abuse AT mcgill DOT ca
X-Trace: carnaval.risq.qc.ca 942767815 132.206.63.174 (Tue, 16 Nov 1999 10:56:55 EST)
NNTP-Posting-Date: Tue, 16 Nov 1999 10:56:55 EST
To: djgpp AT delorie DOT com
DJ-Gateway: from newsgroup comp.os.msdos.djgpp
Reply-To: djgpp AT delorie DOT com

Hans-Bernhard Broeker (broeker AT acp3bf DOT knirsch DOT de) wrote:
: Alain Magloire (alainm AT news DOT mcgill DOT ca) wrote:
: > Malcolm (donald DOT mcleanNOdoSPAM AT talk21 DOT com DOT invalid) wrote:
: > : What does strset do ? I imagine it sets a string to all one
: > : character. This is easy to code
: [...]
: > Then, in that case you are better off with memset() which on most
: > OS/libc coded in assembly for speed.

: Wrong, at least for some applications. The difference is that you have
: to know the length of the string to be 'blanked out', before you can
: call memset(), i.e. strset(string, c) would be equivalent to

: 	memset(string, c, strlen(string));

: That's two loops over the string, one to find its end, the second to
: fill it with 'c'. Almost certainly slower than strset, if that is
: implemented in the straightforward way demonstrated by the posting you
: answered to. Two loops doing so little are practically always slower
: than one, even if both of them are especially cleverly written, and
: the single loop is just compiled ordinarily.

Allright, Fair enough, for that particular example, especially as you pointed
out the length is unknown.  But I will still advocate to use What you got,
and Frankly Hans, I admit no more beleiving in little speed tricks, as you
demostrated above.  When programing on modern CPUs like the PPC, MIPS etc
with branch prediction, branch folding, out-of-order execution etc ..
It's better to use the full extent of the C lib and let the compiler
do it's magic.

Nevertheless your point is well taken.

--
au revoir, alain
----
Aussi haut que l'on soit assis, on est toujours assis que sur son cul !!!

- Raw text -


  webmaster     delorie software   privacy  
  Copyright © 2019   by DJ Delorie     Updated Jul 2019