fast code and no morals

Kenneth Almquist ka at hropus.UUCP
Tue Jan 28 17:25:15 AEST 1986


>>> Here's a version of calloc that breaks every rule of "structured"
>>> programming ever invented -- and runs about twice as fast as a
>>> vanilla version:
>> 
>> So what?  This can be written "structured", and would be more
>> maintainable if it were.  Surely this is not an example of
>> recommended practice?
>
> Sure is recommended if you are optimizing for speed, which is what I assume
> is being done here.  Since calloc is part of the system, and is assumed to
> not have to be changed, maintainability is not the question.  Speed is the
> answer.

"Assumed to not have to be changed!!!???"  I shouldn't even have to
mention the machine dependencies in this code or the coming of "void *";
I can assure you that any code that is used must be maintained.

As for the importance of speed, I have learnt the hard way to
think about what the code is supposed to do before I start hacking
at it.  The System V Release 2 calloc is not only clear and short
(three lines of C code), it is no doubt *faster* than the posted
calloc to boot.
				Kenneth Almquist
				ihnp4!houxm!hropus!ka	(official name)
				ihnp4!opus!ka		(shorter path)



More information about the Comp.lang.c mailing list