Path: utzoo!attcan!uunet!mcsun!ukc!edcastle!aipna!rjc From: rjc@uk.ac.ed.cstr (Richard Caley) Newsgroups: comp.lang.c Subject: Re: May too many register variables hurt? (was Re: Novice question.) Message-ID: Date: 29 Nov 90 01:27:24 GMT References: <967@mwtech.UUCP> <1990Nov21.221908.19871@cbnewsm.att.com> <976@mwtech.UUCP> <9733:Nov2722:02:3090@kramden.acf.nyu.edu> Sender: news@aipna.ed.ac.uk Organization: Center for Speech Technology Research Lines: 37 In-reply-to: brnstnd@kramden.acf.nyu.edu's message of 27 Nov 90 22:02:30 GMT In article <9733:Nov2722:02:3090@kramden.acf.nyu.edu> brnstnd@kramden.acf.nyu.edu (Dan Bernstein) writes: In typical programs, some variables are used quite a lot, and they should be declared register. Some variables are rarely used, and they shouldn't be declared register. It's better to err on the side of extra register declarations than to pessimize your code in the common case. IMHO, it is better not to declare register variabes unless you need to (i.e. the code won't perform as needed without). Given void tweakit(register struct foobar *lastone) { } vs. void tweakit(struct foobar *lastone) { } I find the second _so_ much more readable that adding in the register for, say, a 10% speedup in a program which runs in 10 seconds is not worth it unless you are _very_ sure that that second is critical and the code is more or less totally stable. If the time _is_ critical then it is not enough to stick in a few register variables anyway, it is time to wheel out the profiler, stare at the assembler output and work out whether floating point arithmetic or jumps are more time critical on your machine. -- rjc@uk.ac.ed.cstr real men don't use typedefs!