Checking arguments.length slow
See original GitHub issueChecking arguments.length slow with Chakra. Here is sample page:
<html>
<body>
<script>
var start = Date.now();
function one(a){
}
function two(a,b){
}
function route(a,b){
switch (arguments.length) {
case 1:
return one(a);
case 2:
return two(a,b);
}
}
for (var i = 0; i<1000000; i++) {
route(1,2);
}
document.write(Date.now() - start);
</script>
</body>
</html>
My results:
- Edge: ~380ms
- Chrome: ~20ms
- Firefox: ~3ms
Issue Analytics
- State:
- Created 7 years ago
- Comments:14 (8 by maintainers)
Top Results From Across the Web
How best to determine if an argument is not sent to the ...
Checking arguments.length exhibits the 'most correct' behaviour, but it might not be feasible if there's more than one optional argument. The ...
Read more >arguments.length - JavaScript - MDN Web Docs
The arguments.length property provides the number of arguments actually passed to a function. This can be more or less than the defined ...
Read more >ARG_MAX, maximum length of arguments for a new process
In a loop with increasing n, the check tries an exec() with an argument length of 2 n (but won't check for n...
Read more >Faster JavaScript calls
We check that we have a mismatch between argument size and parameter count and jump to ArgumentsAdaptorTrampoline . In this built-in, we build ......
Read more >Checking Arguments in R Functions
With ArgumentCheck , we'll create an object that, based on the results of a logical test, will store any error and warning messages...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
This issue will be fixed in https://github.com/Microsoft/ChakraCore/pull/1023. This is a WIP item. strict and non-strict mode should be taken care with this change.
Thanks!