How is array-access compiled?

BlitzMax Forums/BlitzMax Beginners Area/How is array-access compiled?

The forum is locked. These are the original blitzbasic.com forums, kept so they can still be read. No new topics, replies or edits can be made here. To join in, head over to the Blitz3D+ forums.

I am just wondering, if you set up an array for example...


Local myarray:Int[50]

and then you want to access it with...


For Local i:int=0 to 49
   Print myarray[i]
Next

does BlitzMax compile this down to being `hardcoded` to access that array in 4-byte increments? Or does it have to check the type of the array on every access and multiple that size by the offset (plus the base) to get to the data? Or is it more hardcoded - ie it multiplies i by 4 and adds it to the base address then reads?

Also, would it be faster then to use an array of Bytes rather than an array of Ints, so that the multiplication (or left shift) to jump to the appropriate location can be eliminated?