|
|
@@ -2,36 +2,50 @@ import { hash, hashString } from '../../nodes/core/NodeUtils.js';
|
|
|
|
|
|
let _id = 0;
|
|
|
|
|
|
+const prototypeKeys = new WeakMap();
|
|
|
+
|
|
|
function getKeys( obj ) {
|
|
|
|
|
|
const keys = Object.keys( obj );
|
|
|
|
|
|
- let proto = Object.getPrototypeOf( obj );
|
|
|
+ const proto = Object.getPrototypeOf( obj );
|
|
|
+ let cachedKeys = prototypeKeys.get( proto );
|
|
|
+
|
|
|
+ if ( cachedKeys === undefined ) {
|
|
|
|
|
|
- while ( proto ) {
|
|
|
+ cachedKeys = [];
|
|
|
+ let p = proto;
|
|
|
|
|
|
- const descriptors = Object.getOwnPropertyDescriptors( proto );
|
|
|
+ while ( p ) {
|
|
|
|
|
|
- for ( const key in descriptors ) {
|
|
|
+ const descriptors = Object.getOwnPropertyDescriptors( p );
|
|
|
|
|
|
- if ( descriptors[ key ] !== undefined ) {
|
|
|
+ for ( const key in descriptors ) {
|
|
|
|
|
|
- const descriptor = descriptors[ key ];
|
|
|
+ if ( descriptors[ key ] !== undefined ) {
|
|
|
|
|
|
- if ( descriptor && typeof descriptor.get === 'function' ) {
|
|
|
+ const descriptor = descriptors[ key ];
|
|
|
|
|
|
- keys.push( key );
|
|
|
+ if ( descriptor && typeof descriptor.get === 'function' ) {
|
|
|
+
|
|
|
+ cachedKeys.push( key );
|
|
|
+
|
|
|
+ }
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ p = Object.getPrototypeOf( p );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- proto = Object.getPrototypeOf( proto );
|
|
|
+ prototypeKeys.set( proto, cachedKeys );
|
|
|
|
|
|
}
|
|
|
|
|
|
+ keys.push( ...cachedKeys );
|
|
|
+
|
|
|
return keys;
|
|
|
|
|
|
}
|