metafizzy / packery

:bento: Gapless, draggable grid layouts
https://packery.metafizzy.co
4.14k stars 315 forks source link

Possible getItem() efficiency concern #480

Closed dvstans closed 6 years ago

dvstans commented 6 years ago

This is not a bug, but while troubleshooting an unrelated problem I noticed the code for the Packery getItem(elem) function compares elements using the == operator. I believe this will compare all fields in the elements, which there are many, but it seems only the "id" fields needs to be compared. I hacked my local packery code to do this, and it seems to work fine.

desandro commented 6 years ago

Thanks for reporting this issue. I consider this kind of code a micro-optimization. Checking == is easily readable and understandable for other developers. I don't feel making a change here would produce much benefit.

Thanks! but I'll have to pass on this one.