mirror of
https://github.com/swc-project/swc.git
synced 2024-12-23 05:32:09 +03:00
fix(es/minifier): Make sequences
less aggressive (#3480)
swc_ecma_minifier: - `sequences`: Abort on RHS contains the left id.
This commit is contained in:
parent
484cd92959
commit
292add7d26
@ -15,4 +15,4 @@ someFunction({
|
||||
someProperty: 42
|
||||
}), someFunction(void 0);
|
||||
let i = 0;
|
||||
for(; (null === (ref8 = arr[i]) || void 0 === ref8 ? void 0 : ref8.tag) === "left";)(null === (ref19 = arr[i += 1]) || void 0 === ref19 ? void 0 : ref19.tag) === "right" && console.log("I should ALSO be reachable");
|
||||
for(; (null === (ref8 = arr[i]) || void 0 === ref8 ? void 0 : ref8.tag) === "left";)i += 1, (null === (ref19 = arr[i]) || void 0 === ref19 ? void 0 : ref19.tag) === "right" && console.log("I should ALSO be reachable");
|
||||
|
@ -4,4 +4,4 @@ function someFunction(someOptionalObject) {
|
||||
null == o || o[a = 1], a.toString(), null == o || o.x[b = 1], b.toString(), null == o || o(c = 1), c.toString(), null == o || o.x(d = 1), d.toString(), null == f || f(x), f(x), f(x), (null == o2 ? void 0 : o2.f(x)) ? (o2.f, null == o2 || o2.f, null == o2 || o2.f(x)) : (null == o2 || o2.f, o2.f), null == o2 || o2.f, o2.f, (null == o3 ? void 0 : o3.x) === 1 ? (o3.x, null == o3 || o3.x) : (null == o3 || o3.x, o3.x), null == o3 || o3.x, o3.x, (null === (ref = o4.x) || void 0 === ref ? void 0 : ref.y) ? (o4.x, o4.x.y, null === (ref9 = o4.x) || void 0 === ref9 || ref9.y) : (o4.x, null === (ref10 = o4.x) || void 0 === ref10 || ref10.y, o4.x.y), o4.x, null === (ref1 = o4.x) || void 0 === ref1 || ref1.y, o4.x.y, (null === (ref3 = null === (ref2 = o5.x) || void 0 === ref2 ? void 0 : ref2.y.z) || void 0 === ref3 ? void 0 : ref3.w) ? (o5.x, o5.x.y, o5.x.y.z, o5.x.y.z.w, null === (ref11 = o5.x.y.z) || void 0 === ref11 || ref11.w, null === (ref12 = o5.x) || void 0 === ref12 || ref12.y.z.w, null === (ref14 = null === (ref13 = o5.x) || void 0 === ref13 ? void 0 : ref13.y.z) || void 0 === ref14 || ref14.w) : (o5.x, null === (ref15 = o5.x) || void 0 === ref15 || ref15.y, null === (ref16 = o5.x) || void 0 === ref16 || ref16.y.z, null === (ref18 = null === (ref17 = o5.x) || void 0 === ref17 ? void 0 : ref17.y.z) || void 0 === ref18 || ref18.w, o5.x.y, o5.x.y.z.w), o5.x, null === (ref4 = o5.x) || void 0 === ref4 || ref4.y, null === (ref5 = o5.x) || void 0 === ref5 || ref5.y.z, null === (ref7 = null === (ref6 = o5.x) || void 0 === ref6 ? void 0 : ref6.y.z) || void 0 === ref7 || ref7.w, o5.x.y, o5.x.y.z.w, (null == o6 ? void 0 : o6.f()) || null == o6 || o6.f, o6.f, null == o6 || o6.f, o6.f, someFunction({
|
||||
someProperty: 42
|
||||
}), someFunction(void 0);
|
||||
for(var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, a, b, c, d, ref9, ref10, ref11, ref12, ref13, ref14, ref15, ref16, ref17, ref18, lastSomeProperty, ref19, i = 0; (null === (ref8 = arr[i]) || void 0 === ref8 ? void 0 : ref8.tag) === "left";)(null === (ref19 = arr[i += 1]) || void 0 === ref19 ? void 0 : ref19.tag) === "right" && console.log("I should ALSO be reachable");
|
||||
for(var ref, ref1, ref2, ref3, ref4, ref5, ref6, ref7, ref8, a, b, c, d, ref9, ref10, ref11, ref12, ref13, ref14, ref15, ref16, ref17, ref18, lastSomeProperty, ref19, i = 0; (null === (ref8 = arr[i]) || void 0 === ref8 ? void 0 : ref8.tag) === "left";)i += 1, (null === (ref19 = arr[i]) || void 0 === ref19 ? void 0 : ref19.tag) === "right" && console.log("I should ALSO be reachable");
|
||||
|
@ -1 +1 @@
|
||||
(Ca.test(c.href) || Ba.test(c.href) && /(\\?|&)adurl=/.test(c.href) && !/(\\?|&)q=/.test(c.href)) && (/ (\\ ? | & ) rct = j /.test(c.href) || (d += "&rct=j"), /(\\?|&)q=/.test(c.href) || (d = (d += "&q=" + encodeURIComponent(W("q") || W("as_q") || A)).substring(0, 1948 - c.href.length)), b = !0);
|
||||
(Ca.test(c.href) || Ba.test(c.href) && /(\\?|&)adurl=/.test(c.href) && !/(\\?|&)q=/.test(c.href)) && (/ (\\ ? | & ) rct = j /.test(c.href) || (d += "&rct=j"), /(\\?|&)q=/.test(c.href) || (d += "&q=" + encodeURIComponent(W("q") || W("as_q") || A), d = d.substring(0, 1948 - c.href.length)), b = !0);
|
||||
|
@ -1 +1 @@
|
||||
(Ca.test(c.href) || Ba.test(c.href) && /(\\?|&)adurl=/.test(c.href) && !/(\\?|&)q=/.test(c.href)) && (/ (\\ ? | & ) rct = j /.test(c.href) || (d += "&rct=j"), /(\\?|&)q=/.test(c.href) || (d = (d += "&q=" + encodeURIComponent(W("q") || W("as_q") || A)).substring(0, 1948 - c.href.length)), b = !0);
|
||||
(Ca.test(c.href) || Ba.test(c.href) && /(\\?|&)adurl=/.test(c.href) && !/(\\?|&)q=/.test(c.href)) && (/ (\\ ? | & ) rct = j /.test(c.href) || (d += "&rct=j"), /(\\?|&)q=/.test(c.href) || (d += "&q=" + encodeURIComponent(W("q") || W("as_q") || A), d = d.substring(0, 1948 - c.href.length)), b = !0);
|
||||
|
@ -15,7 +15,8 @@ use swc_atoms::js_word;
|
||||
use swc_common::{util::take::Take, Spanned, DUMMY_SP};
|
||||
use swc_ecma_ast::*;
|
||||
use swc_ecma_utils::{
|
||||
contains_this_expr, ident::IdentLike, undefined, ExprExt, Id, StmtLike, UsageFinder,
|
||||
contains_arguments, contains_this_expr, ident::IdentLike, undefined, ExprExt, Id, StmtLike,
|
||||
UsageFinder,
|
||||
};
|
||||
use swc_ecma_visit::{noop_visit_type, Visit, VisitWith};
|
||||
use tracing::{span, Level};
|
||||
@ -1008,13 +1009,13 @@ where
|
||||
|
||||
Expr::Assign(b @ AssignExpr { op: op!("="), .. }) => {
|
||||
match &mut b.left {
|
||||
PatOrExpr::Expr(b) => {
|
||||
PatOrExpr::Expr(b_left) => {
|
||||
tracing::trace!("seq: Try lhs of assign");
|
||||
if self.merge_sequential_expr(a, &mut **b)? {
|
||||
if self.merge_sequential_expr(a, &mut **b_left)? {
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
match &**b {
|
||||
match &**b_left {
|
||||
Expr::Ident(..) => {}
|
||||
|
||||
_ => {
|
||||
@ -1022,14 +1023,14 @@ where
|
||||
}
|
||||
}
|
||||
}
|
||||
PatOrExpr::Pat(b) => match &mut **b {
|
||||
Pat::Expr(b) => {
|
||||
PatOrExpr::Pat(b_left) => match &mut **b_left {
|
||||
Pat::Expr(b_left) => {
|
||||
tracing::trace!("seq: Try lhs of assign");
|
||||
if self.merge_sequential_expr(a, &mut **b)? {
|
||||
if self.merge_sequential_expr(a, &mut **b_left)? {
|
||||
return Ok(true);
|
||||
}
|
||||
|
||||
match &**b {
|
||||
match &**b_left {
|
||||
Expr::Ident(..) => {}
|
||||
_ => {
|
||||
return Ok(false);
|
||||
@ -1041,11 +1042,19 @@ where
|
||||
},
|
||||
}
|
||||
|
||||
if should_not_check_rhs_of_assign(a, b) {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
tracing::trace!("seq: Try rhs of assign");
|
||||
return self.merge_sequential_expr(a, &mut b.right);
|
||||
}
|
||||
|
||||
Expr::Assign(b) => {
|
||||
if should_not_check_rhs_of_assign(a, b) {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
let b_left = b.left.as_ident();
|
||||
let b_left = match b_left {
|
||||
Some(v) => v.clone(),
|
||||
@ -1368,10 +1377,7 @@ where
|
||||
if right.is_this() || right.is_ident_ref_to(js_word!("arguments")) {
|
||||
return Ok(false);
|
||||
}
|
||||
if idents_used_by_ignoring_nested(&**right)
|
||||
.iter()
|
||||
.any(|v| v.0 == js_word!("arguments"))
|
||||
{
|
||||
if contains_arguments(&**right) {
|
||||
return Ok(false);
|
||||
}
|
||||
|
||||
@ -1446,6 +1452,31 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
/// TODO(kdy1): Optimize this
|
||||
///
|
||||
/// See https://github.com/swc-project/swc/pull/3480
|
||||
///
|
||||
/// This works, but it should be optimized.
|
||||
///
|
||||
/// This check blocks optimization of clearly valid optimizations like `i += 1,
|
||||
/// arr[i]`
|
||||
fn should_not_check_rhs_of_assign(a: &Mergable, b: &mut AssignExpr) -> bool {
|
||||
if let Some(a_id) = a.id() {
|
||||
match a {
|
||||
Mergable::Expr(Expr::Assign(AssignExpr { op: op!("="), .. })) => {}
|
||||
Mergable::Expr(Expr::Assign(..)) => {
|
||||
let used_by_b = idents_used_by(&*b.right);
|
||||
if used_by_b.contains(&a_id) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
||||
struct UsageCounter<'a> {
|
||||
expr_usage: usize,
|
||||
pat_usage: usize,
|
||||
|
@ -474,9 +474,9 @@
|
||||
case 2:
|
||||
h ^= (255 & str.charCodeAt(i + 1)) << 8;
|
||||
case 1:
|
||||
h = (65535 & (h ^= 255 & str.charCodeAt(i))) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
||||
h ^= 255 & str.charCodeAt(i), h = (65535 & h) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
||||
}
|
||||
return (((h = (65535 & (h ^= h >>> 13)) * 1540483477 + ((h >>> 16) * 59797 << 16)) ^ h >>> 15) >>> 0).toString(36);
|
||||
return h ^= h >>> 13, (((h = (65535 & h) * 1540483477 + ((h >>> 16) * 59797 << 16)) ^ h >>> 15) >>> 0).toString(36);
|
||||
}, unitless_browser_esm = {
|
||||
animationIterationCount: 1,
|
||||
borderImageOutset: 1,
|
||||
|
@ -54,9 +54,9 @@ var cursor, hyphenateRegex = /[A-Z]|^ms/g, animationRegex = /_EMO_([^_]+?)_([^]*
|
||||
case 2:
|
||||
h ^= (255 & str.charCodeAt(i + 1)) << 8;
|
||||
case 1:
|
||||
h = (65535 & (h ^= 255 & str.charCodeAt(i))) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
||||
h ^= 255 & str.charCodeAt(i), h = (65535 & h) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
||||
}
|
||||
return (((h = (65535 & (h ^= h >>> 13)) * 1540483477 + ((h >>> 16) * 59797 << 16)) ^ h >>> 15) >>> 0).toString(36);
|
||||
return h ^= h >>> 13, (((h = (65535 & h) * 1540483477 + ((h >>> 16) * 59797 << 16)) ^ h >>> 15) >>> 0).toString(36);
|
||||
};
|
||||
function handleInterpolation(mergedProps, registered, interpolation) {
|
||||
if (null == interpolation) return "";
|
||||
|
@ -2285,7 +2285,7 @@
|
||||
case "\x01":
|
||||
const n14 = t.substring(r, e);
|
||||
let o;
|
||||
0 === i.length ? o = n14 : (o = i += n14, i = ""), s.push(o);
|
||||
0 === i.length ? o = n14 : (i += n14, o = i, i = ""), s.push(o);
|
||||
break;
|
||||
case "\x10":
|
||||
i += t.substring(r, e), i += "\x00";
|
||||
|
@ -1804,7 +1804,7 @@
|
||||
return this.isValid() ? this._milliseconds + 86400000 * this._days + this._months % 12 * 2592000000 + 31536000000 * toInt(this._months / 12) : NaN;
|
||||
}, proto$2._bubble = function() {
|
||||
var seconds, minutes, hours, years, monthsFromDays, milliseconds = this._milliseconds, days = this._days, months = this._months, data = this._data;
|
||||
return milliseconds >= 0 && days >= 0 && months >= 0 || milliseconds <= 0 && days <= 0 && months <= 0 || (milliseconds += 86400000 * absCeil(monthsToDays(months) + days), days = 0, months = 0), data.milliseconds = milliseconds % 1000, seconds = absFloor(milliseconds / 1000), data.seconds = seconds % 60, minutes = absFloor(seconds / 60), data.minutes = minutes % 60, hours = absFloor(minutes / 60), data.hours = hours % 24, days += absFloor(hours / 24), monthsFromDays = absFloor(daysToMonths(days)), months += monthsFromDays, days -= absCeil(monthsToDays(monthsFromDays)), years = absFloor(months / 12), months %= 12, data.days = days, data.months = months, data.years = years, this;
|
||||
return milliseconds >= 0 && days >= 0 && months >= 0 || milliseconds <= 0 && days <= 0 && months <= 0 || (milliseconds += 86400000 * absCeil(monthsToDays(months) + days), days = 0, months = 0), data.milliseconds = milliseconds % 1000, seconds = absFloor(milliseconds / 1000), data.seconds = seconds % 60, minutes = absFloor(seconds / 60), data.minutes = minutes % 60, hours = absFloor(minutes / 60), data.hours = hours % 24, days += absFloor(hours / 24), months += monthsFromDays = absFloor(daysToMonths(days)), days -= absCeil(monthsToDays(monthsFromDays)), years = absFloor(months / 12), months %= 12, data.days = days, data.months = months, data.years = years, this;
|
||||
}, proto$2.clone = function() {
|
||||
return createDuration(this);
|
||||
}, proto$2.get = function(units) {
|
||||
|
@ -6,7 +6,7 @@ export default function murmur2(str) {
|
||||
case 2:
|
||||
h ^= (255 & str.charCodeAt(i + 1)) << 8;
|
||||
case 1:
|
||||
h = (65535 & (h ^= 255 & str.charCodeAt(i))) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
||||
h ^= 255 & str.charCodeAt(i), h = (65535 & h) * 1540483477 + ((h >>> 16) * 59797 << 16);
|
||||
}
|
||||
return (((h = (65535 & (h ^= h >>> 13)) * 1540483477 + ((h >>> 16) * 59797 << 16)) ^ h >>> 15) >>> 0).toString(36);
|
||||
return h ^= h >>> 13, (((h = (65535 & h) * 1540483477 + ((h >>> 16) * 59797 << 16)) ^ h >>> 15) >>> 0).toString(36);
|
||||
};
|
||||
|
@ -780,7 +780,7 @@
|
||||
for(i = 0, overAvg = 0; i < patches.length; i++)overAvg += (patch = patches[i]).rad, _config.debug.showPatches && _common_image_debug__WEBPACK_IMPORTED_MODULE_5__.a.drawRect(patch.pos, _subImageWrapper.size, _canvasContainer.ctx.binary, {
|
||||
color: "red"
|
||||
});
|
||||
for((overAvg = (180 * (overAvg /= patches.length) / Math.PI + 90) % 180 - 90) < 0 && (overAvg += 180), overAvg = (180 - overAvg) * Math.PI / 180, transMat = gl_mat2__WEBPACK_IMPORTED_MODULE_1__.copy(gl_mat2__WEBPACK_IMPORTED_MODULE_1__.create(), [
|
||||
for(overAvg /= patches.length, (overAvg = (180 * overAvg / Math.PI + 90) % 180 - 90) < 0 && (overAvg += 180), overAvg = (180 - overAvg) * Math.PI / 180, transMat = gl_mat2__WEBPACK_IMPORTED_MODULE_1__.copy(gl_mat2__WEBPACK_IMPORTED_MODULE_1__.create(), [
|
||||
Math.cos(overAvg),
|
||||
Math.sin(overAvg),
|
||||
-Math.sin(overAvg),
|
||||
@ -5062,7 +5062,7 @@
|
||||
value: function() {
|
||||
for(var start = this._nextUnset(this._row), end = start, i = 1; i < this._counters.length; i++){
|
||||
var pattern = this._toPattern(i);
|
||||
if (-1 !== pattern && this._isStartEnd(pattern)) return end = (start += this._sumCounters(0, i)) + this._sumCounters(i, i + 8), {
|
||||
if (-1 !== pattern && this._isStartEnd(pattern)) return start += this._sumCounters(0, i), end = start + this._sumCounters(i, i + 8), {
|
||||
start: start,
|
||||
end: end,
|
||||
startCounter: i,
|
||||
|
@ -1353,7 +1353,7 @@
|
||||
var adjust = Math.max(0, start - Math.min(endA, endB));
|
||||
preferredPos -= endA + adjust - start;
|
||||
}
|
||||
return endA < start && a.size < b.size ? (endB = (start -= preferredPos <= start && preferredPos >= endA ? start - preferredPos : 0) + (endB - endA), endA = start) : endB < start && (endA = (start -= preferredPos <= start && preferredPos >= endB ? start - preferredPos : 0) + (endA - endB), endB = start), {
|
||||
return endA < start && a.size < b.size ? (start -= preferredPos <= start && preferredPos >= endA ? start - preferredPos : 0, endB = start + (endB - endA), endA = start) : endB < start && (start -= preferredPos <= start && preferredPos >= endB ? start - preferredPos : 0, endA = start + (endA - endB), endB = start), {
|
||||
start: start,
|
||||
endA: endA,
|
||||
endB: endB
|
||||
|
@ -8423,11 +8423,11 @@
|
||||
];
|
||||
}, videoTrun = function(track, offset) {
|
||||
var bytesOffest, bytes, header, samples, sample, i;
|
||||
for(offset += 20 + 16 * (samples = track.samples || []).length, header = trunHeader(samples, offset), bytes = new Uint8Array(header.length + 16 * samples.length), bytes.set(header), bytesOffest = header.length, i = 0; i < samples.length; i++)sample = samples[i], bytes[bytesOffest++] = (4278190080 & sample.duration) >>> 24, bytes[bytesOffest++] = (16711680 & sample.duration) >>> 16, bytes[bytesOffest++] = (65280 & sample.duration) >>> 8, bytes[bytesOffest++] = 255 & sample.duration, bytes[bytesOffest++] = (4278190080 & sample.size) >>> 24, bytes[bytesOffest++] = (16711680 & sample.size) >>> 16, bytes[bytesOffest++] = (65280 & sample.size) >>> 8, bytes[bytesOffest++] = 255 & sample.size, bytes[bytesOffest++] = sample.flags.isLeading << 2 | sample.flags.dependsOn, bytes[bytesOffest++] = sample.flags.isDependedOn << 6 | sample.flags.hasRedundancy << 4 | sample.flags.paddingValue << 1 | sample.flags.isNonSyncSample, bytes[bytesOffest++] = 61440 & sample.flags.degradationPriority, bytes[bytesOffest++] = 15 & sample.flags.degradationPriority, bytes[bytesOffest++] = (4278190080 & sample.compositionTimeOffset) >>> 24, bytes[bytesOffest++] = (16711680 & sample.compositionTimeOffset) >>> 16, bytes[bytesOffest++] = (65280 & sample.compositionTimeOffset) >>> 8, bytes[bytesOffest++] = 255 & sample.compositionTimeOffset;
|
||||
for(offset += 20 + 16 * (samples = track.samples || []).length, header = trunHeader(samples, offset), (bytes = new Uint8Array(header.length + 16 * samples.length)).set(header), bytesOffest = header.length, i = 0; i < samples.length; i++)sample = samples[i], bytes[bytesOffest++] = (4278190080 & sample.duration) >>> 24, bytes[bytesOffest++] = (16711680 & sample.duration) >>> 16, bytes[bytesOffest++] = (65280 & sample.duration) >>> 8, bytes[bytesOffest++] = 255 & sample.duration, bytes[bytesOffest++] = (4278190080 & sample.size) >>> 24, bytes[bytesOffest++] = (16711680 & sample.size) >>> 16, bytes[bytesOffest++] = (65280 & sample.size) >>> 8, bytes[bytesOffest++] = 255 & sample.size, bytes[bytesOffest++] = sample.flags.isLeading << 2 | sample.flags.dependsOn, bytes[bytesOffest++] = sample.flags.isDependedOn << 6 | sample.flags.hasRedundancy << 4 | sample.flags.paddingValue << 1 | sample.flags.isNonSyncSample, bytes[bytesOffest++] = 61440 & sample.flags.degradationPriority, bytes[bytesOffest++] = 15 & sample.flags.degradationPriority, bytes[bytesOffest++] = (4278190080 & sample.compositionTimeOffset) >>> 24, bytes[bytesOffest++] = (16711680 & sample.compositionTimeOffset) >>> 16, bytes[bytesOffest++] = (65280 & sample.compositionTimeOffset) >>> 8, bytes[bytesOffest++] = 255 & sample.compositionTimeOffset;
|
||||
return box(types.trun, bytes);
|
||||
}, audioTrun = function(track, offset) {
|
||||
var bytes, bytesOffest, header, samples, sample, i;
|
||||
for(offset += 20 + 8 * (samples = track.samples || []).length, header = trunHeader(samples, offset), bytes = new Uint8Array(header.length + 8 * samples.length), bytes.set(header), bytesOffest = header.length, i = 0; i < samples.length; i++)sample = samples[i], bytes[bytesOffest++] = (4278190080 & sample.duration) >>> 24, bytes[bytesOffest++] = (16711680 & sample.duration) >>> 16, bytes[bytesOffest++] = (65280 & sample.duration) >>> 8, bytes[bytesOffest++] = 255 & sample.duration, bytes[bytesOffest++] = (4278190080 & sample.size) >>> 24, bytes[bytesOffest++] = (16711680 & sample.size) >>> 16, bytes[bytesOffest++] = (65280 & sample.size) >>> 8, bytes[bytesOffest++] = 255 & sample.size;
|
||||
for(offset += 20 + 8 * (samples = track.samples || []).length, header = trunHeader(samples, offset), (bytes = new Uint8Array(header.length + 8 * samples.length)).set(header), bytesOffest = header.length, i = 0; i < samples.length; i++)sample = samples[i], bytes[bytesOffest++] = (4278190080 & sample.duration) >>> 24, bytes[bytesOffest++] = (16711680 & sample.duration) >>> 16, bytes[bytesOffest++] = (65280 & sample.duration) >>> 8, bytes[bytesOffest++] = 255 & sample.duration, bytes[bytesOffest++] = (4278190080 & sample.size) >>> 24, bytes[bytesOffest++] = (16711680 & sample.size) >>> 16, bytes[bytesOffest++] = (65280 & sample.size) >>> 8, bytes[bytesOffest++] = 255 & sample.size;
|
||||
return box(types.trun, bytes);
|
||||
}, trun$1 = function(track, offset) {
|
||||
return "audio" === track.type ? audioTrun(track, offset) : videoTrun(track, offset);
|
||||
@ -8805,7 +8805,7 @@
|
||||
},
|
||||
calculateTrackBaseMediaDecodeTime: function(track, keepOriginalTimestamps) {
|
||||
var baseMediaDecodeTime, minSegmentDts = track.minSegmentDts;
|
||||
return keepOriginalTimestamps || (minSegmentDts -= track.timelineStartInfo.dts), baseMediaDecodeTime = track.timelineStartInfo.baseMediaDecodeTime, baseMediaDecodeTime = Math.max(0, baseMediaDecodeTime += minSegmentDts), "audio" === track.type && (baseMediaDecodeTime = Math.floor(baseMediaDecodeTime *= track.samplerate / ONE_SECOND_IN_TS$3)), baseMediaDecodeTime;
|
||||
return keepOriginalTimestamps || (minSegmentDts -= track.timelineStartInfo.dts), baseMediaDecodeTime = track.timelineStartInfo.baseMediaDecodeTime, baseMediaDecodeTime += minSegmentDts, baseMediaDecodeTime = Math.max(0, baseMediaDecodeTime), "audio" === track.type && (baseMediaDecodeTime *= track.samplerate / ONE_SECOND_IN_TS$3, baseMediaDecodeTime = Math.floor(baseMediaDecodeTime)), baseMediaDecodeTime;
|
||||
},
|
||||
collectDtsInfo: function(track, data) {
|
||||
"number" == typeof data.pts && (void 0 === track.timelineStartInfo.pts && (track.timelineStartInfo.pts = data.pts), void 0 === track.minSegmentPts ? track.minSegmentPts = data.pts : track.minSegmentPts = Math.min(track.minSegmentPts, data.pts), void 0 === track.maxSegmentPts ? track.maxSegmentPts = data.pts : track.maxSegmentPts = Math.max(track.maxSegmentPts, data.pts)), "number" == typeof data.dts && (void 0 === track.timelineStartInfo.dts && (track.timelineStartInfo.dts = data.dts), void 0 === track.minSegmentDts ? track.minSegmentDts = data.dts : track.minSegmentDts = Math.min(track.minSegmentDts, data.dts), void 0 === track.maxSegmentDts ? track.maxSegmentDts = data.dts : track.maxSegmentDts = Math.max(track.maxSegmentDts, data.dts));
|
||||
@ -9651,7 +9651,7 @@
|
||||
workingBytes.set(workingData.subarray(position, position + availableBytes)), workingWord = new DataView(workingBytes.buffer).getUint32(0), workingBitsAvailable = 8 * availableBytes, workingBytesAvailable -= availableBytes;
|
||||
}, this.skipBits = function(count) {
|
||||
var skipBytes;
|
||||
workingBitsAvailable > count ? (workingWord <<= count, workingBitsAvailable -= count) : (count -= 8 * (skipBytes = Math.floor((count -= workingBitsAvailable) / 8)), workingBytesAvailable -= skipBytes, this.loadWord(), workingWord <<= count, workingBitsAvailable -= count);
|
||||
workingBitsAvailable > count ? (workingWord <<= count, workingBitsAvailable -= count) : (count -= workingBitsAvailable, count -= 8 * (skipBytes = Math.floor(count / 8)), workingBytesAvailable -= skipBytes, this.loadWord(), workingWord <<= count, workingBitsAvailable -= count);
|
||||
}, this.readBits = function(size) {
|
||||
var bits = Math.min(workingBitsAvailable, size), valu = workingWord >>> 32 - bits;
|
||||
return ((workingBitsAvailable -= bits) > 0 ? workingWord <<= bits : workingBytesAvailable > 0 && this.loadWord(), (bits = size - bits) > 0) ? valu << bits | this.readBits(bits) : valu;
|
||||
|
@ -0,0 +1,8 @@
|
||||
export function log2(v) {
|
||||
var r, shift;
|
||||
r = (v > 0xFFFF) << 4; v >>>= r;
|
||||
shift = (v > 0xFF) << 3; v >>>= shift; r |= shift;
|
||||
shift = (v > 0xF) << 2; v >>>= shift; r |= shift;
|
||||
shift = (v > 0x3) << 1; v >>>= shift; r |= shift;
|
||||
return r | (v >> 1);
|
||||
}
|
@ -0,0 +1,4 @@
|
||||
export function log2(v) {
|
||||
var r, shift;
|
||||
return v >>>= r = (v > 65535) << 4, v >>>= shift = (v > 255) << 3, r |= shift, shift = (v > 15) << 2, v >>>= shift, r |= shift, shift = (v > 3) << 1, v >>>= shift, r |= shift, r | v >> 1;
|
||||
}
|
@ -9563,3 +9563,27 @@ console.log(murmur2("1va1ns`klj"));"###;
|
||||
|
||||
run_exec_test(src, config, false);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn plotly_1() {
|
||||
let src = r###"
|
||||
function log2(v) {
|
||||
var r, shift;
|
||||
r = (v > 0xFFFF) << 4; v >>>= r;
|
||||
shift = (v > 0xFF ) << 3; v >>>= shift; r |= shift;
|
||||
shift = (v > 0xF ) << 2; v >>>= shift; r |= shift;
|
||||
shift = (v > 0x3 ) << 1; v >>>= shift; r |= shift;
|
||||
return r | (v >> 1);
|
||||
}
|
||||
console.log(log2(65536))
|
||||
console.log(log2(2))
|
||||
console.log(log2(4))
|
||||
console.log(log2(8))
|
||||
"###;
|
||||
let config = r###"{
|
||||
"defaults": true,
|
||||
"toplevel": true
|
||||
}"###;
|
||||
|
||||
run_exec_test(src, config, false);
|
||||
}
|
||||
|
File diff suppressed because one or more lines are too long
@ -5305,7 +5305,7 @@
|
||||
if (!didWarnAboutMismatchedHooksForComponent.has(componentName) && (didWarnAboutMismatchedHooksForComponent.add(componentName), null !== hookTypesDev)) {
|
||||
for(var table = "", secondColumnStart = 30, i = 0; i <= hookTypesUpdateIndexDev; i++){
|
||||
for(var oldHookName = hookTypesDev[i], newHookName = i === hookTypesUpdateIndexDev ? currentHookName : oldHookName, row = i + 1 + ". " + oldHookName; row.length < secondColumnStart;)row += " ";
|
||||
table += row += newHookName + "\n";
|
||||
row += newHookName + "\n", table += row;
|
||||
}
|
||||
error1("React has detected a change in the order of Hooks called by %s. This will lead to bugs and errors if not fixed. For more information, read the Rules of Hooks: https://reactjs.org/link/rules-of-hooks\n\n Previous render Next render\n ------------------------------------------------------\n%s ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^\n", componentName, table);
|
||||
}
|
||||
|
@ -106,6 +106,7 @@
|
||||
"optimizable",
|
||||
"paren",
|
||||
"Paren",
|
||||
"plotly",
|
||||
"pmutil",
|
||||
"pointee",
|
||||
"prec",
|
||||
|
Loading…
Reference in New Issue
Block a user