aboutsummaryrefslogtreecommitdiff
path: root/src/js_parser.zig
diff options
context:
space:
mode:
Diffstat (limited to 'src/js_parser.zig')
-rw-r--r--src/js_parser.zig16
1 files changed, 10 insertions, 6 deletions
diff --git a/src/js_parser.zig b/src/js_parser.zig
index 05966b745..2ee274e92 100644
--- a/src/js_parser.zig
+++ b/src/js_parser.zig
@@ -4388,7 +4388,7 @@ pub const KnownGlobal = enum {
pub const map = bun.ComptimeEnumMap(KnownGlobal);
- pub fn maybeMarkConstructorAsPure(e: *E.New, symbols: []const Symbol) void {
+ pub noinline fn maybeMarkConstructorAsPure(e: *E.New, symbols: []const Symbol) void {
const id = if (e.target.data == .e_identifier) e.target.data.e_identifier.ref else return;
const symbol = &symbols[id.innerIndex()];
if (symbol.kind != .unbound)
@@ -4407,7 +4407,7 @@ pub const KnownGlobal = enum {
}
if (n == 1) {
- switch (e.args[0].data) {
+ switch (e.args.ptr[0].data) {
.e_null, .e_undefined => {
// "new WeakSet(null)" is pure
// "new WeakSet(void 0)" is pure
@@ -4437,7 +4437,7 @@ pub const KnownGlobal = enum {
}
if (n == 1) {
- switch (e.args[0].knownPrimitiveType()) {
+ switch (e.args.ptr[0].knownPrimitive()) {
.null, .undefined, .boolean, .number, .string => {
// "new Date('')" is pure
// "new Date(0)" is pure
@@ -4465,7 +4465,7 @@ pub const KnownGlobal = enum {
}
if (n == 1) {
- switch (e.args[0].data) {
+ switch (e.args.ptr[0].data) {
.e_array, .e_null, .e_undefined => {
// "new Set([a, b, c])" is pure
// "new Set(null)" is pure
@@ -4489,7 +4489,7 @@ pub const KnownGlobal = enum {
}
if (n == 1) {
- switch (e.args[0].data) {
+ switch (e.args.ptr[0].data) {
.e_null, .e_undefined => {
// "new Map(null)" is pure
// "new Map(void 0)" is pure
@@ -4497,7 +4497,7 @@ pub const KnownGlobal = enum {
},
.e_array => |array| {
var all_items_are_arrays = true;
- for (array.items) |item| {
+ for (array.items.slice()) |item| {
if (item.data != .e_array) {
all_items_are_arrays = false;
break;
@@ -16343,6 +16343,10 @@ fn NewParser_(
for (e_.args.slice()) |*arg| {
arg.* = p.visitExpr(arg.*);
}
+
+ if (p.options.features.minify_syntax) {
+ KnownGlobal.maybeMarkConstructorAsPure(e_, p.symbols.items);
+ }
},
.e_arrow => |e_| {
if (p.is_revisit_for_substitution) {