Skip to content

Commit e96a05d

Browse files
authored
Performance: improve objectWithoutPropertiesLoose on V8 (#16357)
1 parent c6f1e73 commit e96a05d

3 files changed

Lines changed: 12 additions & 15 deletions

File tree

‎packages/babel-helpers/src/helpers.ts‎

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -344,13 +344,12 @@ helpers.objectWithoutPropertiesLoose = helper("7.0.0-beta.0")`
344344
if (source == null) return {};
345345
346346
var>
347-
var sourceKeys = Object.keys(source);
348-
var key, i;
349347
350-
for (i = 0; i < sourceKeys.length; i++) {
351-
key = sourceKeys[i];
352-
if (excluded.indexOf(key) >= 0) continue;
353-
target[key] = source[key];
348+
for (var key in source) {
349+
if (Object.prototype.hasOwnProperty.call(source, key)) {
350+
if (excluded.indexOf(key) >= 0) continue;
351+
target[key] = source[key];
352+
}
354353
}
355354
356355
return target;

‎packages/babel-preset-env/test/fixtures/corejs2-babel-7/usage-shippedProposals/output.js‎

Lines changed: 2 additions & 2 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.
Lines changed: 5 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,14 +1,12 @@
1-
import _Object$keys from "core-js-pure/features/object/keys.js";
21
import _indexOfInstanceProperty from "core-js-pure/features/instance/index-of.js";
32
export default function _objectWithoutPropertiesLoose(source, excluded) {
43
if (source == null) return {};
54
var target = {};
6-
var sourceKeys = _Object$keys(source);
7-
var key, i;
8-
for (i = 0; i < sourceKeys.length; i++) {
9-
key = sourceKeys[i];
10-
if (_indexOfInstanceProperty(excluded).call(excluded, key) >= 0) continue;
11-
target[key] = source[key];
5+
for (var key in source) {
6+
if (Object.prototype.hasOwnProperty.call(source, key)) {
7+
if (_indexOfInstanceProperty(excluded).call(excluded, key) >= 0) continue;
8+
target[key] = source[key];
9+
}
1210
}
1311
return target;
1412
}

0 commit comments

Comments
 (0)