Simple optimization question on array vs hardcoding.

Hey guys :3
So you will have to forgive my ignorance as i’ve been coding in unity for only over a month now. but I was trying to find answers in the documentation searching up keywords like arrays and hardcoding in google but with no clear answers. This isn’t really a problem, more so just curious what is more appropriate way to code based on this circumstance:

so all i have is an effect in Ugui where futuristic UI elements have random numbers “calculating” for added futuristic effect. the numbers are only there for aesthetics.

to get the changing numbers i currently use a corutine set to .1 WaitForSeconds that multiplies a float by random.range and outputs that number to string. the effect looks great, however because the number is something i don’t care about and can literally be anything, would it be more efficient to simply hardcode lets say 13 different numbers and iterate between them in a for loop? I know they say hardcoding should be avoided as much as possible but in this circumstance would it make more sense to do so just so it’s not processing otherwise numbers we don’t care about?

thanks for any help :slight_smile:

The processing power is not really a issue but if you like to trade the bit processing power and probably regularly memory allocations against a small fixed memory block for storing the numbers sure why not.

If you have a missive amount of thous scripts in your scene, you may be interested in storing it in a static array so all your script can access the same numbers without allocation them again and again.