clintbellanger / flare

Free Libre Action Roleplaying Engine
http://clintbellanger.net/rpg/
GNU General Public License v3.0
166 stars 41 forks source link

remove duplicate code. #911

Closed stefanbeller closed 11 years ago

clintbellanger commented 11 years ago

Should this parameter be a pointer or reference instead? Make sure it's not actually copying 64k short values just to call these functions:

const unsigned short layerdata[256][256]
stefanbeller commented 11 years ago

@clintbellanger yes this is what I actually thought about as well. Apparently in c/c++ arrays are the only data type which are passed by reference by default (i.e. pointer to the first element of the array)

Notice that in the header file it is only

const unsigned short layerdata[][256]

in the parameter list which is the same as a pointer to arrays of size 256. I actually benchmarked the system and could not find any difference in cpuload or memory usage. Also I tried rewriting the given parameters as references or such, but this way is the only really understandable way to write it down and it still compiles. :/