Artemix
Artemix

Reputation: 8655

Is doing this: var[property] more resource intensive than var.property?

I'm about to refactor a long algorithm so it can be adapted to any property instead of a fixed one.

So, instead of having var.x I would have var[property], where property can be x, y, alpha, etc.

But, a question appeared, performance wise, does it present an impact?.

Thanks!

Upvotes: 0

Views: 31

Answers (1)

Esailija
Esailija

Reputation: 140230

In relative terms yes it's slower, whether that matters depends on deep specifics of your application and its usage patterns.

Upvotes: 1

Related Questions