Skip to content

Commit

Permalink
perf: preinitialize typeCheck RegExp (#10990)
Browse files Browse the repository at this point in the history
  • Loading branch information
SebastianSpeitel committed Mar 30, 2021
1 parent 55a30cf commit 2488a6a
Showing 1 changed file with 3 additions and 1 deletion.
4 changes: 3 additions & 1 deletion src/core/util/props.js
Expand Up @@ -174,13 +174,15 @@ function assertType (value: any, type: Function): {
}
}

const functionTypeCheckRE = /^\s*function (\w+)/

/**
* Use function string name to check built-in types,
* because a simple equality check will fail when running
* across different vms / iframes.
*/
function getType (fn) {
const match = fn && fn.toString().match(/^\s*function (\w+)/)
const match = fn && fn.toString().match(functionTypeCheckRE)
return match ? match[1] : ''
}

Expand Down

0 comments on commit 2488a6a

Please sign in to comment.