Skip to content

Commit

Permalink
lib: simplify own keys retrieval
Browse files Browse the repository at this point in the history
This replacement can save us a function call, two array spreadings,
and an array concatenation.

PR-URL: #24582
Refs: https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Reflect/ownKeys#Description
Reviewed-By: Anna Henningsen <anna@addaleax.net>
Reviewed-By: Gus Caplan <me@gus.host>
Reviewed-By: Colin Ihrig <cjihrig@gmail.com>
  • Loading branch information
vsemozhetbyt authored and rvagg committed Nov 28, 2018
1 parent 35a7646 commit b2c243f
Showing 1 changed file with 1 addition and 3 deletions.
4 changes: 1 addition & 3 deletions lib/internal/safe_globals.js
Original file line number Diff line number Diff line change
@@ -1,9 +1,7 @@
'use strict';

const copyProps = (unsafe, safe) => {
for (const key of [...Object.getOwnPropertyNames(unsafe),
...Object.getOwnPropertySymbols(unsafe)
]) {
for (const key of Reflect.ownKeys(unsafe)) {
if (!Object.getOwnPropertyDescriptor(safe, key)) {
Object.defineProperty(
safe,
Expand Down

0 comments on commit b2c243f

Please sign in to comment.