Author: Robert Hyatt
Date: 18:05:27 10/26/01
Go up one level in this thread
On October 26, 2001 at 16:56:19, Derek Mauro wrote: >As far as I can tell, static and global variables seem to be equally efficient, >the only difference being that statics have a limited scope. Am I right, or is >one actually more efficient than the other? Is there any advantage to passing >around a static or a global? I've always read that globals should be avoided. >Is there any performance reason why? You are correct. Globals should be avoided for software engineering reasons, not performance-related reasons. No reason one should be faster or slower than the other, with one minor point... static (local static) variables are going to be located close together in memory. Which helps with cache pre-fetching. Global variables _can_ be placed close together if you remember to do so. But they could be wildly separated as well since they are part of a much bigger group of variables... > >Thanks for your help in advance.
This page took 0 seconds to execute
Last modified: Thu, 15 Apr 21 08:11:13 -0700
Current Computer Chess Club Forums at Talkchess. This site by Sean Mintz.