@@ -12560,7 +12560,8 @@ Compressor.prototype.compress = function(node) {
|
||||
var found = false;
|
||||
var generated = false;
|
||||
var keep_duplicate = compressor.has_directive("use strict");
|
||||
var keys = new Dictionary();
|
||||
var keys = [];
|
||||
var map = new Dictionary();
|
||||
var values = [];
|
||||
self.properties.forEach(function(prop) {
|
||||
if (!(prop instanceof AST_Spread)) return process(prop);
|
||||
@@ -12603,19 +12604,27 @@ Compressor.prototype.compress = function(node) {
|
||||
return make_node(AST_Object, self, { properties: values });
|
||||
|
||||
function flush() {
|
||||
keys.each(function(props) {
|
||||
if (props.length == 1) return values.push(props[0]);
|
||||
keys.forEach(function(key) {
|
||||
var props = map.get(key);
|
||||
switch (props.length) {
|
||||
case 0:
|
||||
return;
|
||||
case 1:
|
||||
return values.push(props[0]);
|
||||
}
|
||||
changed = true;
|
||||
var tail = keep_duplicate && !generated && props.pop();
|
||||
values.push(props.length == 1 ? props[0] : make_node(AST_ObjectKeyVal, self, {
|
||||
key: props[0].key,
|
||||
value: make_sequence(self, props.map(function(prop) {
|
||||
return prop.value;
|
||||
}))
|
||||
})),
|
||||
}));
|
||||
if (tail) values.push(tail);
|
||||
props.length = 0;
|
||||
});
|
||||
keys = new Dictionary();
|
||||
keys = [];
|
||||
map = new Dictionary();
|
||||
}
|
||||
|
||||
function process(prop) {
|
||||
@@ -12631,14 +12640,15 @@ Compressor.prototype.compress = function(node) {
|
||||
}
|
||||
if (can_hoist_property(prop)) {
|
||||
if (prop.value.has_side_effects(compressor)) flush();
|
||||
keys.add(key, prop);
|
||||
keys.push(key);
|
||||
map.add(key, prop);
|
||||
} else {
|
||||
flush();
|
||||
values.push(prop);
|
||||
}
|
||||
if (found && !generated && typeof key == "string" && RE_POSITIVE_INTEGER.test(key)) {
|
||||
generated = true;
|
||||
if (keys.has(key)) prop = keys.get(key)[0];
|
||||
if (map.has(key)) prop = map.get(key)[0];
|
||||
prop.key = make_node(AST_Number, prop, { value: +key });
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user