On 09/01/2017 01:18 PM, Boris Zbarsky wrote:
That has the unfortunate side-effect of allocating a new JS string for every call, but we can probably optimize it if it becomes necessary.

We could add a hasClassName if we wanted.

I'm kind of missing what's better about this compared to the other suggestion of hasInstance() (thanks to Botond for catching my English mistake!) I'm worried a bit because of the string compare that this involves.

I think for things like this, as micro-optimization-land as this may sound, we should keep performance in mind, and before making a call we should try to see which variant would be faster. Where we're bikeshedding over the cosmetics of the API, we should consider letting the faster variant win. It's easy to write this off as non-important right now but generic facilities like this are bound to be used some day in a hot loop somewhere and then fixing things may be too costly due to having to change all of the existing code.

Cheers,
Ehsan
_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to