Repository navigation
Cache match elements to speed up compiler - #1831
Conversation
|
Btw, won't the caching break matching of interpolated selectors? I guess the "element expansion" should only be cached when selector contains no |
There was a problem hiding this comment.
This make sense. But unfortunately there're too many possible value types beyond a string (e.g. an array, an expression etc.) so it still remains broken for "complex" variable values... Ideally we should use element.genCSS() instead of simple element.value expansion for interpolated things everywhere.
I was also thinking of something like that (i.e. caching + proper @{var} expansion) but I thought it would make sense to fix #1196 first which means this whole thing to be completely rewritten from scratch (because we will need to switch from the "element by element" to a "string/substring" matching method or a sort of).
I looked into that as well but decided to go with this for a two reasons.
oelements = other.elements.map( function(v) {
return v.combinator.value + (v.value.value || v.value);
}).join("").match(/[,&#\.\w-]([\w-]|(\\.))*/g);
.class[a=1]{
...
}
Just checked and this compiles correctly: @var: one;
.mixin-@{var}{
width:10;
}
.test{
.mixin-one;
} |
Yes. I mean situations like this: I.e. the test for "string" type does not really improve anything.
I meant more tricky situations where the value of a variable used in selector changes in between mixin calls. Well, I did some testing and it seems that for the moment there's no way to achive anything like that, so indeed caching can't break anything. A code to illustrate what I mean: There
Sorry, wrong issue number, I meant #1270 and similar, i.e.: |
|
Either way the performance improvement seems to be quite noticeable (it's 10-15% improvement for the less.benchmark which does not use too many mixin calls, so it should be even faster for things like Bootstrap). So personally I sympathize merging this. |
There was a problem hiding this comment.
Btw, var i is not declared here (so grunt test fails).
|
okay then, merged |
No description provided.