mirror of
https://github.com/scratchfoundation/scratch-vm.git
synced 2024-12-24 06:52:40 -05:00
Write src/engine/execute so it can be optimized
Testing with implicitly casted `value` and `value.then` is deoptimizing isPromise, which deoptimizes execute. In this case deoptimizing means that the JavaScript VM cannot compile the functions into a form that can be run faster.
This commit is contained in:
parent
ef961c5a4b
commit
cd9004ce5b
1 changed files with 5 additions and 1 deletions
|
@ -8,7 +8,11 @@ const {Map} = require('immutable');
|
|||
* @return {boolean} True if the value appears to be a Promise.
|
||||
*/
|
||||
const isPromise = function (value) {
|
||||
return value && value.then && typeof value.then === 'function';
|
||||
return (
|
||||
value !== null &&
|
||||
typeof value === 'object' &&
|
||||
typeof value.then === 'function'
|
||||
);
|
||||
};
|
||||
|
||||
/**
|
||||
|
|
Loading…
Reference in a new issue