diasurgical / devilutionX

Diablo build for modern operating systems
Other
8.01k stars 786 forks source link

Optimize GetPlayerGraphicForSpell #7210

Closed kphoenix137 closed 2 months ago

kphoenix137 commented 2 months ago

Improves performance and maintainability by using a lookup table instead of switch-case conditions.

StephenCWills commented 2 months ago

I'm not sure that unordered_map is really going to perform better than the switch-case with just three options.

kphoenix137 commented 2 months ago

I'm not sure that unordered_map is really going to perform better than the switch-case with just three options.

I'm sure the difference is negligible in this case. Which one is more user friendly for modification?

StephenCWills commented 2 months ago

Which one is more user friendly for modification?

Neither. The code is all here in this one tiny method, and modification can be mostly a copy/paste job either way.

kphoenix137 commented 2 months ago

Which one is more user friendly for modification?

Neither. The code is all here in this one tiny method, and modification can be mostly a copy/paste job either way.

Sounds good, I will close.