Path: utzoo!utgpu!water!watmath!clyde!att!osu-cis!tut.cis.ohio-state.edu!mailrus!ames!umd5!cvl!mimsy!chris
From: chris@mimsy.UUCP (Chris Torek)
Newsgroups: comp.misc
Subject: Re: Basics of Program Design
Message-ID: <12328@mimsy.UUCP>
Date: 6 Jul 88 07:52:47 GMT
References: <901@td2cad.intel.com> <3061@rpp386.UUCP> <395@proxftl.UUCP> <430@proxftl.UUCP>
Distribution: na
Organization: U of Maryland, Dept. of Computer Science, Coll. Pk., MD 20742
Lines: 25

In article <430@proxftl.UUCP> bill@proxftl.UUCP (T. William Wells) writes:
>... try to make everything you do [including strlen()]
>as good as you can. The notion that a routine is only going to be
>used a small fraction of the time is no excuse for sloppiness.

Actually, strlen is all too often more than just a few percent.  This
shows up in particular on 4.3BSD on the MicroVAX II, where strlen is
implemented using the `locc' instruction.  On the MicroVAX II this
instruction is not implemented in hardware, and causes a trap to
emulation code.  Unfortunately, the fancy locc version is almost as
much faster on the other VAXen as it is slower on the uVAX II, when
compared with the obvious version.

>Learning is a cumulative process. This little bitty routine that
>will not be executed much is as good a place for thinking about
>efficiency as any other, and possibly better. Do it enough and
>efficient coding becomes second nature. Then you will naturally
>write efficient programs ....

(wow, someone agrees with me :-) )  This needs to be tempered a bit,
though: there is usually no point in optimising the test in main to see
whether argc is correct....
-- 
In-Real-Life: Chris Torek, Univ of MD Comp Sci Dept (+1 301 454 7163)
Domain:	chris@mimsy.umd.edu	Path:	uunet!mimsy!chris