Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Avoid deoptimization in generateCSS() (#204)
I was profiling the css() function and Chrome raised a flag on this function: > Not optimized: Bad value context for arguments value More info on this warning: GoogleChrome/devtools-docs#53 (comment) Looking at the warning and the compiled version of this code, it seems to do some things with `arguments` when using the default values here, which is causing this deoptimization. ```js var selectorHandlers = arguments.length <= 2 || arguments[2] === undefined ? [] : arguments[2]; var stringHandlers = arguments.length <= 3 || arguments[3] === undefined ? {} : arguments[3]; var useImportant = arguments.length <= 4 || arguments[4] === undefined ? true : arguments[4]; ``` By removing the default values for the arguments, the deoptimization disappears. I thought about adding logic that would provide values for these arguments if they aren't defined, but since the only thing that relies on that is tests I decided to just update the tests to always pass all of the arguments. In my benchmark, this does not seem to make much of a difference but it still seems like a good idea to avoid things that the browser tells us is deoptimized.
- Loading branch information