File tree Expand file tree Collapse file tree 1 file changed +17
-2
lines changed
packages/runtime-core/src Expand file tree Collapse file tree 1 file changed +17
-2
lines changed Original file line number Diff line number Diff line change @@ -597,8 +597,23 @@ function validatePropName(key: string) {
597597// use function string name to check type constructors
598598// so that it works across vms / iframes.
599599function getType ( ctor : Prop < any > ) : string {
600- const match = ctor && ctor . toString ( ) . match ( / ^ \s * ( f u n c t i o n | c l a s s ) ( \w + ) / )
601- return match ? match [ 2 ] : ctor === null ? 'null' : ''
600+ // Early return for null to avoid unnecessary computations
601+ if ( ctor === null ) {
602+ return 'null'
603+ }
604+
605+ // Avoid using regex for common cases by checking the type directly
606+ if ( typeof ctor === 'function' ) {
607+ // Using name property to avoid converting function to string
608+ return ctor . name || ''
609+ } else if ( typeof ctor === 'object' ) {
610+ // Attempting to directly access constructor name if possible
611+ const name = ctor . constructor && ctor . constructor . name
612+ return name || ''
613+ }
614+
615+ // Fallback for other types (though they're less likely to have meaningful names here)
616+ return ''
602617}
603618
604619function isSameType ( a : Prop < any > , b : Prop < any > ) : boolean {
You can’t perform that action at this time.
0 commit comments