Speed Key Validation (by over 9000)
Use a valid identifier (and non-string) to reduce chance of de-optimizing in V8 and Nitro.
Tim Yung committed
Oct 7, 2013 at 14:55 UTC
0c59c57d66d83481795408cd7697c46a3a7dbf9a
1 file changed
+3
-9
src/core/ReactComponent.js
+3
-9
@@ -27,12 +27,6 @@ var invariant = require('invariant');
27
var keyMirror = require('keyMirror');
28
var merge = require('merge');
29
30
-/**
31
- * Props key that determines if a component's key was already validated.
32
- * @private
33
- */
34
-var IS_KEY_VALIDATED = '{is.key.validated}';
35
-
30
/**
31
* Every React component is in one of these life cycles.
32
*/
@@ -65,10 +59,10 @@ var ownerHasWarned = {};
59
* @param {ReactComponent} component Component that requires a key.
60
*/
61
function validateExplicitKey(component) {
68
- if (component[IS_KEY_VALIDATED] || component.props.key != null) {
62
+ if (component.__keyValidated__ || component.props.key != null) {
63
return;
64
}
71
- component[IS_KEY_VALIDATED] = true;
65
+ component.__keyValidated__ = true;
66
67
// We can't provide friendly warnings for top level components.
68
if (!ReactCurrentOwner.current) {
@@ -117,7 +111,7 @@ function validateChildKeys(component) {
111
}
112
} else if (ReactComponent.isValidComponent(component)) {
113
// This component was passed in a valid location.
120
- component[IS_KEY_VALIDATED] = true;
114
+ component.__keyValidated__ = true;
115
}
116
}
117