On Tue, 14 Oct 1997, Rich Chiavaroli wrote: > Some of the snippets and patches I've found define var's as > > register int a; > > I would guess this places this var directly into a resister for faster > access. Well thats what I remember from assembly on a VAX *shudder*. > Now I would guess a piece of code that overuses this won't be that > effective. Otherwise every var would be placed directly into a register. > > Any thoughts on the use of registers, how often to use them, and the most > effective use of them? I recall reading that gcc regards the register as a reccomendation, not as a hard rule. So I suspect that if you were to overuse it, it would only place some of the variables in the registers. It is my suspicion that the most effective use of registers would be variable accessed repeatedly, such as array indicies or loop variables. It requires looking up both array and i to access array[i]. I generally don't bother with them unless I'm trying to optimize something for speed. Even then, I haven't run any careful tests to see if I did actually save any time by declaring the registers, so don't take my words to seriously. :) -Hans +------------------------------------------------------------+ | Ensure that you have read the CircleMUD Mailing List FAQ: | | http://democracy.queensu.ca/~fletcher/Circle/list-faq.html | +------------------------------------------------------------+
This archive was generated by hypermail 2b30 : 12/08/00 PST