visionmedia/jade — pull request #464 by osher (2012-01-05 19:16:58+00:00)
Title: Tag#attrs : array - performance drawback refactor offer

First - I want to say I love what you're doing there. Anyway, I was reading for my own pleasure and then I saw this performance drawback of looping all attributes to remove and to find, where there are simple tools to do better.

I figured that you're using an array because in some stage of the program you need to loop it using an Array API, and secondly because you might want to allow same attribute to be added several times (if both assumptions are wrong - then array is a bad choice, you just as well use an object ).
So, what I propose here is an index map, where every key is the attribute name, and every value is an array of the indexes this attribute appears.
The current API returns the first occurency of the attribute in the tag - which leaves open for cases the attribute is pushed several times...

Good luck :)