Even if it is obvious, I see juniors doing this a lot. It happens fast if you're deep into solving a challenge. Take your time and have a second look at every piece of code you wrote.
It doesn't seem like a big deal, but if your codebase grows and performance gets a critical point in your application this small mistakes add up quickly.
Never do repetive heavy calculations in frequently called code (eg loops).
Of course only if the input to the heavy method isn't changing.
Top comments (1)
Whenever necessary, I also employ currying for my functions so that I wouldn't have to insert the same arguments over and over again. I'm pretty sure it's a "micro-optimization", but it does save me from the verbosity.