|
|
@@ -1,37 +1,45 @@
|
|
|
import { hash, hashString } from '../../nodes/core/NodeUtils.js';
|
|
|
|
|
|
let _id = 0;
|
|
|
+const _protoKeysCache = new WeakMap();
|
|
|
|
|
|
function getKeys( obj ) {
|
|
|
|
|
|
const keys = Object.keys( obj );
|
|
|
|
|
|
- let proto = Object.getPrototypeOf( obj );
|
|
|
+ let protoKeys = _protoKeysCache.get( obj.constructor );
|
|
|
|
|
|
- while ( proto ) {
|
|
|
+ if ( protoKeys === undefined ) {
|
|
|
|
|
|
- const descriptors = Object.getOwnPropertyDescriptors( proto );
|
|
|
+ protoKeys = [];
|
|
|
+ let proto = Object.getPrototypeOf( obj );
|
|
|
|
|
|
- for ( const key in descriptors ) {
|
|
|
+ while ( proto ) {
|
|
|
|
|
|
- if ( descriptors[ key ] !== undefined ) {
|
|
|
+ const descriptors = Object.getOwnPropertyDescriptors( proto );
|
|
|
+
|
|
|
+ for ( const key in descriptors ) {
|
|
|
|
|
|
const descriptor = descriptors[ key ];
|
|
|
|
|
|
if ( descriptor && typeof descriptor.get === 'function' ) {
|
|
|
|
|
|
- keys.push( key );
|
|
|
+ protoKeys.push( key );
|
|
|
|
|
|
}
|
|
|
|
|
|
}
|
|
|
|
|
|
+ proto = Object.getPrototypeOf( proto );
|
|
|
+
|
|
|
}
|
|
|
|
|
|
- proto = Object.getPrototypeOf( proto );
|
|
|
+ _protoKeysCache.set( obj.constructor, protoKeys );
|
|
|
|
|
|
}
|
|
|
|
|
|
+ for ( let i = 0; i < protoKeys.length; i ++ ) keys.push( protoKeys[ i ] );
|
|
|
+
|
|
|
return keys;
|
|
|
|
|
|
}
|