File tree 1 file changed +17
-2
lines changed
packages/runtime-core/src
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) {
597
597
// use function string name to check type constructors
598
598
// so that it works across vms / iframes.
599
599
function 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 ''
602
617
}
603
618
604
619
function isSameType ( a : Prop < any > , b : Prop < any > ) : boolean {
You can’t perform that action at this time.
0 commit comments