optimization - Should I pass a commonly used array using a reference or by value in a game [C++] -


this simple, wanted feedback, guess.

long story short super novice programming, , i've (about 6 months ago) started doing game programming, , it's going fine. can work , that, that's not question. instead, has passing objects.

pretty pass same object or variable several times through game loop. so, cameras, camera used draw objects. first camera passed container object (like drawing frames of animation, animation object contains frames), passes individual object, draws. now, passes camera maybe 3 times max, it's no worry, yet.

what more concerning similar multiple-passing array of tiles makes map. first array passed 'update' function of player or enemy, passed individual move , input functions check collisions, , in functions it's passed collision detection function. anyway, pretty happens object (in case, array of 100~1000 tiles) gets passed 4-5 times per game loop. wondering if should use constant reference instead of passing on , on again.

pretty minor overhead issue, , think know answer, don't want change functions find out made application slower (not since runs @ 800 fps right now).

if can modify programming style include techniques make code perform better, without costing far maintenance or readability goes, should it.

beyond this, optimizations should limited instances know need it, because have measured performance , found lacking.


Comments

Popular posts from this blog

android - Spacing between the stars of a rating bar? -

aspxgridview - Devexpress grid - header filter does not work if column is initially hidden -

c# - How to execute a particular part of code asynchronously in a class -