-
Notifications
You must be signed in to change notification settings - Fork 5.7k
fix(ext/node): use primordials in ext/node/polyfills/internal_binding/util.ts
#30014
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Conversation
`ext/node/polyfills/internal_binding/util.ts`
let allProperties = [ | ||
...Object.getOwnPropertyNames(obj), | ||
...Object.getOwnPropertySymbols(obj), | ||
...new SafeArrayIterator(ObjectGetOwnPropertyNames(obj)), | ||
...new SafeArrayIterator(ObjectGetOwnPropertySymbols(obj)), | ||
]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It seems better to use Reflect.ownKeys
.
let allProperties = ReflectOwnKeys(obj);
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This makes sense. I've updated it. Thank you for your review!
for (const key of new SafeArrayIterator(allProperties)) { | ||
const desc = ObjectGetOwnPropertyDescriptor(obj, key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
SafeArrayIterator
has a slight performance cost, I would like to use a simple loop based on the index.
for (const key of new SafeArrayIterator(allProperties)) { | |
const desc = ObjectGetOwnPropertyDescriptor(obj, key); | |
for (let i = 0; i < allProperties.length; ++i) { | |
const key = allProperties[i]; | |
const desc = ObjectGetOwnPropertyDescriptor(obj, key); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ditto.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks!
Towards #24236. Replaces JS builtins with equivalent primordials.