mirror of
https://github.com/swc-project/swc.git
synced 2024-11-23 09:38:16 +03:00
feat(es/minifier): Implement more rules for optimizing for-if-break (#4140)
This commit is contained in:
parent
3c4c3a6087
commit
ee5c48c935
@ -134,10 +134,6 @@ where
|
||||
}
|
||||
}
|
||||
|
||||
pub(super) fn drop_if_break(&mut self, _s: &ForStmt) {
|
||||
if !self.options.loops {}
|
||||
}
|
||||
|
||||
///
|
||||
/// - `for (a(), 5; b(); c())` => `for (a(); b(); c())`
|
||||
pub(super) fn optimize_init_of_for_stmt(&mut self, s: &mut ForStmt) {
|
||||
|
@ -2050,8 +2050,6 @@ where
|
||||
s.visit_mut_children_with(&mut *self.with_ctx(ctx));
|
||||
|
||||
self.with_ctx(ctx).optimize_init_of_for_stmt(s);
|
||||
|
||||
self.with_ctx(ctx).drop_if_break(s);
|
||||
}
|
||||
|
||||
#[cfg_attr(feature = "debug", tracing::instrument(skip_all))]
|
||||
|
@ -44,6 +44,95 @@ impl Pure<'_> {
|
||||
}
|
||||
}
|
||||
|
||||
/// ## Input
|
||||
/// ```js
|
||||
/// for(; bar();){
|
||||
/// if (x(), y(), foo()) break;
|
||||
/// z(), k();
|
||||
/// }
|
||||
/// ```
|
||||
///
|
||||
/// ## Output
|
||||
///
|
||||
/// ```js
|
||||
/// for(; bar() && (x(), y(), !foo());)z(), k();
|
||||
/// ```
|
||||
pub(super) fn optimize_for_if_break(&mut self, s: &mut ForStmt) -> Option<()> {
|
||||
if !self.options.loops {
|
||||
return None;
|
||||
}
|
||||
|
||||
if let Stmt::Block(body) = &mut *s.body {
|
||||
let first = body.stmts.get_mut(0)?;
|
||||
|
||||
if let Stmt::If(IfStmt {
|
||||
span,
|
||||
test,
|
||||
cons,
|
||||
alt: None,
|
||||
..
|
||||
}) = first
|
||||
{
|
||||
if let Stmt::Break(BreakStmt { label: None, .. }) = &**cons {
|
||||
self.negate(test, false, false);
|
||||
|
||||
match s.test.as_deref_mut() {
|
||||
Some(e) => {
|
||||
let orig_test = e.take();
|
||||
*e = Expr::Bin(BinExpr {
|
||||
span: *span,
|
||||
op: op!("&&"),
|
||||
left: Box::new(orig_test),
|
||||
right: test.take(),
|
||||
});
|
||||
}
|
||||
None => {
|
||||
s.test = Some(test.take());
|
||||
}
|
||||
}
|
||||
|
||||
tracing::debug!("loops: Optimizing a for loop with an if-then-break");
|
||||
|
||||
first.take();
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
if let Stmt::If(IfStmt {
|
||||
span,
|
||||
test,
|
||||
cons,
|
||||
alt: Some(alt),
|
||||
..
|
||||
}) = first
|
||||
{
|
||||
if let Stmt::Break(BreakStmt { label: None, .. }) = &**alt {
|
||||
match s.test.as_deref_mut() {
|
||||
Some(e) => {
|
||||
let orig_test = e.take();
|
||||
*e = Expr::Bin(BinExpr {
|
||||
span: *span,
|
||||
op: op!("&&"),
|
||||
left: Box::new(orig_test),
|
||||
right: test.take(),
|
||||
});
|
||||
}
|
||||
None => {
|
||||
s.test = Some(test.take());
|
||||
}
|
||||
}
|
||||
|
||||
tracing::debug!("loops: Optimizing a for loop with an if-else-break");
|
||||
|
||||
*first = *cons.take();
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
||||
/// # Input
|
||||
///
|
||||
/// ```js
|
||||
|
@ -367,6 +367,8 @@ impl VisitMut for Pure<'_> {
|
||||
fn visit_mut_for_stmt(&mut self, s: &mut ForStmt) {
|
||||
s.visit_mut_children_with(self);
|
||||
|
||||
self.optimize_for_if_break(s);
|
||||
|
||||
self.merge_for_if_break(s);
|
||||
|
||||
if let Some(test) = &mut s.test {
|
||||
|
@ -526,12 +526,7 @@ labels/labels_7/input.js
|
||||
labels/labels_9/input.js
|
||||
logical_assignment/assign_in_conditional_part/input.js
|
||||
logical_assignment/assignment_in_left_part_2/input.js
|
||||
loops/drop_if_break_3/input.js
|
||||
loops/drop_if_break_4/input.js
|
||||
loops/drop_if_else_break_1/input.js
|
||||
loops/drop_if_else_break_2/input.js
|
||||
loops/drop_if_else_break_3/input.js
|
||||
loops/drop_if_else_break_4/input.js
|
||||
loops/issue_2740_3/input.js
|
||||
loops/issue_2740_4/input.js
|
||||
loops/issue_2740_5/input.js
|
||||
|
@ -7547,10 +7547,7 @@
|
||||
string
|
||||
];
|
||||
if (!isRegExp(separator)) return nativeSplit.call(string, separator, lim);
|
||||
for(var output = [], flags = (separator.ignoreCase ? 'i' : '') + (separator.multiline ? 'm' : '') + (separator.unicode ? 'u' : '') + (separator.sticky ? 'y' : ''), lastLastIndex = 0, separatorCopy = new RegExp(separator.source, flags + 'g'); match = regexpExec.call(separatorCopy, string);){
|
||||
if ((lastIndex = separatorCopy.lastIndex) > lastLastIndex && (output.push(string.slice(lastLastIndex, match.index)), match.length > 1 && match.index < string.length && arrayPush.apply(output, match.slice(1)), lastLength = match[0].length, lastLastIndex = lastIndex, output.length >= lim)) break;
|
||||
separatorCopy.lastIndex === match.index && separatorCopy.lastIndex++;
|
||||
}
|
||||
for(var output = [], flags = (separator.ignoreCase ? 'i' : '') + (separator.multiline ? 'm' : '') + (separator.unicode ? 'u' : '') + (separator.sticky ? 'y' : ''), lastLastIndex = 0, separatorCopy = new RegExp(separator.source, flags + 'g'); (match = regexpExec.call(separatorCopy, string)) && (!((lastIndex = separatorCopy.lastIndex) > lastLastIndex) || (output.push(string.slice(lastLastIndex, match.index)), match.length > 1 && match.index < string.length && arrayPush.apply(output, match.slice(1)), lastLength = match[0].length, lastLastIndex = lastIndex, !(output.length >= lim)));)separatorCopy.lastIndex === match.index && separatorCopy.lastIndex++;
|
||||
return lastLastIndex === string.length ? (lastLength || !separatorCopy.test('')) && output.push('') : output.push(string.slice(lastLastIndex)), output.length > lim ? output.slice(0, lim) : output;
|
||||
} : '0'.split(void 0, 0).length ? function(separator, limit) {
|
||||
return void 0 === separator && 0 === limit ? [] : nativeSplit.call(this, separator, limit);
|
||||
@ -15076,10 +15073,7 @@
|
||||
}
|
||||
var u, n = 0, A = -1, p = -1, C = 0, x = 0, w = g, z = null;
|
||||
b: for(;;){
|
||||
for(;;){
|
||||
if (w !== h || 0 !== f && 3 !== w.nodeType || (A = n + f), w !== k || 0 !== l && 3 !== w.nodeType || (p = n + l), 3 === w.nodeType && (n += w.nodeValue.length), null === (u = w.firstChild)) break;
|
||||
z = w, w = u;
|
||||
}
|
||||
for(; w !== h || 0 !== f && 3 !== w.nodeType || (A = n + f), w !== k || 0 !== l && 3 !== w.nodeType || (p = n + l), 3 === w.nodeType && (n += w.nodeValue.length), null !== (u = w.firstChild);)z = w, w = u;
|
||||
for(;;){
|
||||
if (w === g) break b;
|
||||
if (z === h && ++C === f && (A = n), z === k && ++x === l && (p = n), null !== (u = w.nextSibling)) break;
|
||||
|
@ -397,10 +397,7 @@
|
||||
return node1(value, root, parent, DECLARATION, Utility_substr(value, 0, length), Utility_substr(value, length + 1, -1), length);
|
||||
}
|
||||
var identifierWithPointTracking = function(begin, points, index) {
|
||||
for(var previous = 0, character = 0;;){
|
||||
if (previous = character, character = peek(), 38 === previous && 12 === character && (points[index] = 1), token(character)) break;
|
||||
next1();
|
||||
}
|
||||
for(var previous = 0, character = 0; previous = character, character = peek(), 38 === previous && 12 === character && (points[index] = 1), !token(character);)next1();
|
||||
return slice(begin, position);
|
||||
}, toRules = function(parsed, points) {
|
||||
var index = -1, character = 44;
|
||||
|
@ -99,24 +99,21 @@
|
||||
};
|
||||
}
|
||||
function scrollRectIntoView(view, rect, startDOM) {
|
||||
for(var scrollThreshold = view.someProp("scrollThreshold") || 0, scrollMargin = view.someProp("scrollMargin") || 5, doc = view.dom.ownerDocument, parent = startDOM || view.dom;; parent = parentNode(parent)){
|
||||
if (!parent) break;
|
||||
if (1 == parent.nodeType) {
|
||||
var atTop = parent == doc.body || 1 != parent.nodeType, bounding = atTop ? windowRect(doc) : clientRect(parent), moveX = 0, moveY = 0;
|
||||
if (rect.top < bounding.top + getSide(scrollThreshold, "top") ? moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top")) : rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom") && (moveY = rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom")), rect.left < bounding.left + getSide(scrollThreshold, "left") ? moveX = -(bounding.left - rect.left + getSide(scrollMargin, "left")) : rect.right > bounding.right - getSide(scrollThreshold, "right") && (moveX = rect.right - bounding.right + getSide(scrollMargin, "right")), moveX || moveY) if (atTop) doc.defaultView.scrollBy(moveX, moveY);
|
||||
else {
|
||||
var startX = parent.scrollLeft, startY = parent.scrollTop;
|
||||
moveY && (parent.scrollTop += moveY), moveX && (parent.scrollLeft += moveX);
|
||||
var dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY;
|
||||
rect = {
|
||||
left: rect.left - dX,
|
||||
top: rect.top - dY,
|
||||
right: rect.right - dX,
|
||||
bottom: rect.bottom - dY
|
||||
};
|
||||
}
|
||||
if (atTop) break;
|
||||
for(var scrollThreshold = view.someProp("scrollThreshold") || 0, scrollMargin = view.someProp("scrollMargin") || 5, doc = view.dom.ownerDocument, parent = startDOM || view.dom; parent; parent = parentNode(parent))if (1 == parent.nodeType) {
|
||||
var atTop = parent == doc.body || 1 != parent.nodeType, bounding = atTop ? windowRect(doc) : clientRect(parent), moveX = 0, moveY = 0;
|
||||
if (rect.top < bounding.top + getSide(scrollThreshold, "top") ? moveY = -(bounding.top - rect.top + getSide(scrollMargin, "top")) : rect.bottom > bounding.bottom - getSide(scrollThreshold, "bottom") && (moveY = rect.bottom - bounding.bottom + getSide(scrollMargin, "bottom")), rect.left < bounding.left + getSide(scrollThreshold, "left") ? moveX = -(bounding.left - rect.left + getSide(scrollMargin, "left")) : rect.right > bounding.right - getSide(scrollThreshold, "right") && (moveX = rect.right - bounding.right + getSide(scrollMargin, "right")), moveX || moveY) if (atTop) doc.defaultView.scrollBy(moveX, moveY);
|
||||
else {
|
||||
var startX = parent.scrollLeft, startY = parent.scrollTop;
|
||||
moveY && (parent.scrollTop += moveY), moveX && (parent.scrollLeft += moveX);
|
||||
var dX = parent.scrollLeft - startX, dY = parent.scrollTop - startY;
|
||||
rect = {
|
||||
left: rect.left - dX,
|
||||
top: rect.top - dY,
|
||||
right: rect.right - dX,
|
||||
bottom: rect.bottom - dY
|
||||
};
|
||||
}
|
||||
if (atTop) break;
|
||||
}
|
||||
}
|
||||
function scrollStack(dom) {
|
||||
@ -705,8 +702,7 @@
|
||||
}, NodeViewDesc.prototype.protectLocalComposition = function(view, ref) {
|
||||
var node = ref.node, pos = ref.pos, text = ref.text;
|
||||
if (!this.getDesc(node)) {
|
||||
for(var topNode = node;; topNode = topNode.parentNode){
|
||||
if (topNode.parentNode == this.contentDOM) break;
|
||||
for(var topNode = node; topNode.parentNode != this.contentDOM; topNode = topNode.parentNode){
|
||||
for(; topNode.previousSibling;)topNode.parentNode.removeChild(topNode.previousSibling);
|
||||
for(; topNode.nextSibling;)topNode.parentNode.removeChild(topNode.nextSibling);
|
||||
topNode.pmViewDesc && (topNode.pmViewDesc = null);
|
||||
@ -2648,8 +2644,7 @@
|
||||
"IMG" == next.nodeName && (box$1 = next.getBoundingClientRect()).right <= coords3.left && box$1.bottom > coords3.top && offset1++;
|
||||
}
|
||||
node1 == view10.dom && offset1 == node1.childNodes.length - 1 && 1 == node1.lastChild.nodeType && coords3.top > node1.lastChild.getBoundingClientRect().bottom ? pos = view10.state.doc.content.size : (0 == offset1 || 1 != node1.nodeType || "BR" != node1.childNodes[offset1 - 1].nodeName) && (pos = function(view, node, offset, coords) {
|
||||
for(var outside = -1, cur = node;;){
|
||||
if (cur == view.dom) break;
|
||||
for(var outside = -1, cur = node; cur != view.dom;){
|
||||
var desc = view.docView.nearestDesc(cur, !0);
|
||||
if (!desc) return null;
|
||||
if (desc.node.isBlock && desc.parent) {
|
||||
|
@ -484,13 +484,10 @@
|
||||
if (!data.disabled) {
|
||||
event = fixEvent(event);
|
||||
var handlers = data.handlers[event.type];
|
||||
if (handlers) for(var handlersCopy = handlers.slice(0), m = 0, n = handlersCopy.length; m < n; m++){
|
||||
if (event.isImmediatePropagationStopped()) break;
|
||||
try {
|
||||
handlersCopy[m].call(elem, event, hash);
|
||||
} catch (e) {
|
||||
log$1.error(e);
|
||||
}
|
||||
if (handlers) for(var handlersCopy = handlers.slice(0), m = 0, n = handlersCopy.length; m < n && !event.isImmediatePropagationStopped(); m++)try {
|
||||
handlersCopy[m].call(elem, event, hash);
|
||||
} catch (e) {
|
||||
log$1.error(e);
|
||||
}
|
||||
}
|
||||
}), 1 === data.handlers[type].length) if (elem.addEventListener) {
|
||||
@ -8813,8 +8810,7 @@
|
||||
for(var i = 0, result = {
|
||||
payloadType: -1,
|
||||
payloadSize: 0
|
||||
}, payloadType = 0, payloadSize = 0; i < bytes.byteLength;){
|
||||
if (128 === bytes[i]) break;
|
||||
}, payloadType = 0, payloadSize = 0; i < bytes.byteLength && 128 !== bytes[i];){
|
||||
for(; 255 === bytes[i];)payloadType += 255, i++;
|
||||
for(payloadType += bytes[i++]; 255 === bytes[i];)payloadSize += 255, i++;
|
||||
if (payloadSize += bytes[i++], !result.payload && 4 === payloadType) {
|
||||
@ -10093,10 +10089,7 @@
|
||||
nalUnit.data
|
||||
]), nalUnits.push(nalUnit);
|
||||
}, this.flush = function() {
|
||||
for(var alignedGops, frames, gopForFusion, gops, moof, mdat, boxes, firstGop, lastGop, prependedContentDuration = 0; nalUnits.length;){
|
||||
if ('access_unit_delimiter_rbsp' === nalUnits[0].nalUnitType) break;
|
||||
nalUnits.shift();
|
||||
}
|
||||
for(var alignedGops, frames, gopForFusion, gops, moof, mdat, boxes, firstGop, lastGop, prependedContentDuration = 0; nalUnits.length && 'access_unit_delimiter_rbsp' !== nalUnits[0].nalUnitType;)nalUnits.shift();
|
||||
if (0 === nalUnits.length) {
|
||||
this.resetStream_(), this.trigger('done', 'VideoSegmentStream');
|
||||
return;
|
||||
@ -10141,8 +10134,7 @@
|
||||
return nearestGopObj ? nearestGopObj.gop : null;
|
||||
}, this.alignGopsAtStart_ = function(gops) {
|
||||
var alignIndex, gopIndex, align, gop, byteLength, nalCount, duration, alignedGops;
|
||||
for(byteLength = gops.byteLength, nalCount = gops.nalCount, duration = gops.duration, alignIndex = gopIndex = 0; alignIndex < gopsToAlignWith.length && gopIndex < gops.length;){
|
||||
if (align = gopsToAlignWith[alignIndex], gop = gops[gopIndex], align.pts === gop.pts) break;
|
||||
for(byteLength = gops.byteLength, nalCount = gops.nalCount, duration = gops.duration, alignIndex = gopIndex = 0; alignIndex < gopsToAlignWith.length && gopIndex < gops.length && (align = gopsToAlignWith[alignIndex], gop = gops[gopIndex], align.pts !== gop.pts);){
|
||||
if (gop.pts > align.pts) {
|
||||
alignIndex++;
|
||||
continue;
|
||||
|
@ -438,10 +438,7 @@
|
||||
2,
|
||||
1
|
||||
], getLength = function(byte) {
|
||||
for(var len = 1, i = 0; i < LENGTH_TABLE.length; i++){
|
||||
if (byte & LENGTH_TABLE[i]) break;
|
||||
len++;
|
||||
}
|
||||
for(var len = 1, i = 0; i < LENGTH_TABLE.length && !(byte & LENGTH_TABLE[i]); i++)len++;
|
||||
return len;
|
||||
}, getvint = function(bytes, offset, removeLength, signed) {
|
||||
void 0 === removeLength && (removeLength = !0), void 0 === signed && (signed = !1);
|
||||
@ -5787,10 +5784,7 @@
|
||||
return byteArray;
|
||||
}
|
||||
function utf16leToBytes(str, units) {
|
||||
for(var c, hi, lo, byteArray = [], i = 0; i < str.length; ++i){
|
||||
if ((units -= 2) < 0) break;
|
||||
hi = (c = str.charCodeAt(i)) >> 8, lo = c % 256, byteArray.push(lo), byteArray.push(hi);
|
||||
}
|
||||
for(var c, hi, lo, byteArray = [], i = 0; i < str.length && !((units -= 2) < 0); ++i)hi = (c = str.charCodeAt(i)) >> 8, lo = c % 256, byteArray.push(lo), byteArray.push(hi);
|
||||
return byteArray;
|
||||
}
|
||||
function base64ToBytes(str1) {
|
||||
@ -5801,10 +5795,7 @@
|
||||
}(str1));
|
||||
}
|
||||
function blitBuffer(src, dst, offset, length) {
|
||||
for(var i = 0; i < length; ++i){
|
||||
if (i + offset >= dst.length || i >= src.length) break;
|
||||
dst[i + offset] = src[i];
|
||||
}
|
||||
for(var i = 0; i < length && !(i + offset >= dst.length) && !(i >= src.length); ++i)dst[i + offset] = src[i];
|
||||
return i;
|
||||
}
|
||||
function isInstance(obj, type) {
|
||||
|
@ -404,10 +404,7 @@
|
||||
return nstate;
|
||||
}
|
||||
function innerMode(mode, state) {
|
||||
for(var info; mode.innerMode;){
|
||||
if (!(info = mode.innerMode(state)) || info.mode == mode) break;
|
||||
state = info.state, mode = info.mode;
|
||||
}
|
||||
for(var info; mode.innerMode && (info = mode.innerMode(state)) && info.mode != mode;)state = info.state, mode = info.mode;
|
||||
return info || {
|
||||
mode: mode,
|
||||
state: state
|
||||
@ -450,10 +447,7 @@
|
||||
}
|
||||
function lineNo1(line) {
|
||||
if (null == line.parent) return null;
|
||||
for(var cur = line.parent, no = indexOf(cur.lines, line), chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent)for(var i = 0;; ++i){
|
||||
if (chunk.children[i] == cur) break;
|
||||
no += chunk.children[i].chunkSize();
|
||||
}
|
||||
for(var cur = line.parent, no = indexOf(cur.lines, line), chunk = cur.parent; chunk; cur = chunk, chunk = chunk.parent)for(var i = 0; chunk.children[i] != cur; ++i)no += chunk.children[i].chunkSize();
|
||||
return no + cur.first;
|
||||
}
|
||||
function lineAtHeight(chunk, h) {
|
||||
@ -4651,8 +4645,7 @@
|
||||
}
|
||||
if ("char" == unit || "codepoint" == unit) moveOnce();
|
||||
else if ("column" == unit) moveOnce(!0);
|
||||
else if ("word" == unit || "group" == unit) for(var sawType = null, group = "group" == unit, helper = doc.cm && doc.cm.getHelper(pos2, "wordChars"), first = !0;; first = !1){
|
||||
if (dir1 < 0 && !moveOnce(!first)) break;
|
||||
else if ("word" == unit || "group" == unit) for(var sawType = null, group = "group" == unit, helper = doc.cm && doc.cm.getHelper(pos2, "wordChars"), first = !0; !(dir1 < 0) || moveOnce(!first); first = !1){
|
||||
var cur = lineObj.text.charAt(pos2.ch) || "\n", type = isWordChar(cur, helper) ? "w" : group && "\n" == cur ? "n" : !group || /\s/.test(cur) ? null : "p";
|
||||
if (!group || first || type || (type = "s"), sawType && sawType != type) {
|
||||
dir1 < 0 && (dir1 = 1, moveOnce(), pos2.sticky = "after");
|
||||
@ -4669,8 +4662,7 @@
|
||||
var pageSize = Math.min(cm.display.wrapper.clientHeight, window.innerHeight || document.documentElement.clientHeight), moveAmount = Math.max(pageSize - 0.5 * textHeight(cm.display), 3);
|
||||
y = (dir > 0 ? pos.bottom : pos.top) + dir * moveAmount;
|
||||
} else "line" == unit && (y = dir > 0 ? pos.bottom + 3 : pos.top - 3);
|
||||
for(;;){
|
||||
if (!(target = coordsChar(cm, x, y)).outside) break;
|
||||
for(; (target = coordsChar(cm, x, y)).outside;){
|
||||
if (dir < 0 ? y <= 0 : y >= doc.height) {
|
||||
target.hitSide = !0;
|
||||
break;
|
||||
@ -4726,10 +4718,7 @@
|
||||
}
|
||||
} else 3 == node.nodeType && addText(node.nodeValue.replace(/\u200b/g, "").replace(/\u00a0/g, " "));
|
||||
}
|
||||
for(;;){
|
||||
if (walk(from), from == to) break;
|
||||
from = from.nextSibling, extraLinebreak = !1;
|
||||
}
|
||||
for(; walk(from), from != to;)from = from.nextSibling, extraLinebreak = !1;
|
||||
return text;
|
||||
}
|
||||
function domToPos(cm, node, offset) {
|
||||
|
@ -729,10 +729,7 @@
|
||||
return r;
|
||||
}
|
||||
function utf16leToBytes(e, r) {
|
||||
for(var t, f, n, i = [], o = 0; o < e.length; ++o){
|
||||
if ((r -= 2) < 0) break;
|
||||
f = (t = e.charCodeAt(o)) >> 8, n = t % 256, i.push(n), i.push(f);
|
||||
}
|
||||
for(var t, f, n, i = [], o = 0; o < e.length && !((r -= 2) < 0); ++o)f = (t = e.charCodeAt(o)) >> 8, n = t % 256, i.push(n), i.push(f);
|
||||
return i;
|
||||
}
|
||||
function base64ToBytes(e6) {
|
||||
@ -743,10 +740,7 @@
|
||||
}(e6));
|
||||
}
|
||||
function blitBuffer(e, r, t, f) {
|
||||
for(var n = 0; n < f; ++n){
|
||||
if (n + t >= r.length || n >= e.length) break;
|
||||
r[n + t] = e[n];
|
||||
}
|
||||
for(var n = 0; n < f && !(n + t >= r.length) && !(n >= e.length); ++n)r[n + t] = e[n];
|
||||
return n;
|
||||
}
|
||||
function isInstance(e, r) {
|
||||
|
File diff suppressed because one or more lines are too long
@ -826,6 +826,11 @@ loops/dead_code_condition/input.js
|
||||
loops/do_switch/input.js
|
||||
loops/drop_if_break_1/input.js
|
||||
loops/drop_if_break_2/input.js
|
||||
loops/drop_if_break_3/input.js
|
||||
loops/drop_if_break_4/input.js
|
||||
loops/drop_if_else_break_2/input.js
|
||||
loops/drop_if_else_break_3/input.js
|
||||
loops/drop_if_else_break_4/input.js
|
||||
loops/evaluate/input.js
|
||||
loops/in_parenthesis_1/input.js
|
||||
loops/in_parenthesis_2/input.js
|
||||
|
@ -2178,11 +2178,7 @@
|
||||
});
|
||||
},
|
||||
readIdent: function() {
|
||||
for(var lastDot, peekIndex, methodName, ch, parser = this, ident = '', start = this.index; this.index < this.text.length;){
|
||||
if ('.' === (ch = this.text.charAt(this.index)) || this.isIdent(ch) || this.isNumber(ch)) '.' === ch && (lastDot = this.index), ident += ch;
|
||||
else break;
|
||||
this.index++;
|
||||
}
|
||||
for(var lastDot, peekIndex, methodName, ch, parser = this, ident = '', start = this.index; this.index < this.text.length && ('.' === (ch = this.text.charAt(this.index)) || this.isIdent(ch) || this.isNumber(ch));)'.' === ch && (lastDot = this.index), ident += ch, this.index++;
|
||||
if (lastDot) for(peekIndex = this.index; peekIndex < this.text.length;){
|
||||
if ('(' === (ch = this.text.charAt(peekIndex))) {
|
||||
methodName = ident.substr(lastDot - start + 1), ident = ident.substr(0, lastDot - start), this.index = peekIndex;
|
||||
|
@ -1649,12 +1649,9 @@
|
||||
if (!(context = Expr.find.ID(token.matches[0].replace(runescape, funescape), context)[0])) return results;
|
||||
selector = selector.slice(tokens.shift().value.length);
|
||||
}
|
||||
for(i = matchExpr.needsContext.test(selector) ? 0 : tokens.length; i--;){
|
||||
if (token = tokens[i], Expr.relative[type = token.type]) break;
|
||||
if ((find = Expr.find[type]) && (seed = find(token.matches[0].replace(runescape, funescape), rsibling.test(tokens[0].type) && context.parentNode || context))) {
|
||||
if (tokens.splice(i, 1), !(selector = seed.length && toSelector(tokens))) return push.apply(results, slice.call(seed, 0)), results;
|
||||
break;
|
||||
}
|
||||
for(i = matchExpr.needsContext.test(selector) ? 0 : tokens.length; (i--) && (token = tokens[i], !Expr.relative[type = token.type]);)if ((find = Expr.find[type]) && (seed = find(token.matches[0].replace(runescape, funescape), rsibling.test(tokens[0].type) && context.parentNode || context))) {
|
||||
if (tokens.splice(i, 1), !(selector = seed.length && toSelector(tokens))) return push.apply(results, slice.call(seed, 0)), results;
|
||||
break;
|
||||
}
|
||||
}
|
||||
return compile(selector, match)(seed, context, documentIsXML, results, rsibling.test(selector)), results;
|
||||
|
@ -230,10 +230,7 @@
|
||||
$1.mobile.activeClickedLink && (!$1.mobile.activeClickedLink.closest("." + $1.mobile.activePageClass).length || forceRemoval) && $1.mobile.activeClickedLink.removeClass($1.mobile.activeBtnClass), $1.mobile.activeClickedLink = null;
|
||||
},
|
||||
getInheritedTheme: function(el, defaultTheme) {
|
||||
for(var c, m, e = el[0], ltr = "", re = /ui-(bar|body|overlay)-([a-z])\b/; e;){
|
||||
if ((c = e.className || "") && (m = re.exec(c)) && (ltr = m[2])) break;
|
||||
e = e.parentNode;
|
||||
}
|
||||
for(var c, m, e = el[0], ltr = "", re = /ui-(bar|body|overlay)-([a-z])\b/; e && (!((c = e.className || "") && (m = re.exec(c))) || !(ltr = m[2]));)e = e.parentNode;
|
||||
return ltr || defaultTheme || "a";
|
||||
},
|
||||
enhanceable: function(elements) {
|
||||
@ -1621,10 +1618,7 @@
|
||||
}), $15.mobile.navreadyDeferred = $15.Deferred(), pageTransitionQueue = [], isPageTransitioning = !1, function($, undefined) {
|
||||
var domreadyDeferred = $.Deferred(), loadDeferred = $.Deferred(), documentUrl = $.mobile.path.documentUrl, $lastVClicked = null;
|
||||
function findClosestLink(ele) {
|
||||
for(; ele;){
|
||||
if ("string" == typeof ele.nodeName && "a" === ele.nodeName.toLowerCase()) break;
|
||||
ele = ele.parentNode;
|
||||
}
|
||||
for(; ele && ("string" != typeof ele.nodeName || "a" !== ele.nodeName.toLowerCase());)ele = ele.parentNode;
|
||||
return ele;
|
||||
}
|
||||
$.mobile.loadPage = function(url, opts) {
|
||||
|
@ -755,8 +755,7 @@
|
||||
}
|
||||
function workLoop(hasTimeRemaining, initialTime) {
|
||||
var currentTime = initialTime;
|
||||
for(advanceTimers(currentTime), currentTask = peek(taskQueue); null !== currentTask;){
|
||||
if (currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost())) break;
|
||||
for(advanceTimers(currentTime), currentTask = peek(taskQueue); null !== currentTask && !(currentTask.expirationTime > currentTime && (!hasTimeRemaining || shouldYieldToHost()));){
|
||||
var callback = currentTask.callback;
|
||||
if ('function' == typeof callback) {
|
||||
currentTask.callback = null, currentPriorityLevel = currentTask.priorityLevel;
|
||||
|
@ -3602,8 +3602,7 @@
|
||||
return inst || null;
|
||||
}
|
||||
function accumulateEnterLeaveListenersForEvent(dispatchQueue, event, target, common, inCapturePhase) {
|
||||
for(var registrationName = event._reactName, listeners = [], instance = target; null !== instance;){
|
||||
if (instance === common) break;
|
||||
for(var registrationName = event._reactName, listeners = [], instance = target; null !== instance && instance !== common;){
|
||||
var _instance4 = instance, alternate = _instance4.alternate, stateNode = _instance4.stateNode, tag = _instance4.tag;
|
||||
if (null !== alternate && alternate === common) break;
|
||||
if (5 === tag && null !== stateNode) {
|
||||
@ -8443,10 +8442,7 @@
|
||||
return function(outerNode, anchorNode, anchorOffset, focusNode, focusOffset) {
|
||||
var length = 0, start = -1, end = -1, indexWithinAnchor = 0, indexWithinFocus = 0, node = outerNode, parentNode = null;
|
||||
outer: for(;;){
|
||||
for(var next = null;;){
|
||||
if (node === anchorNode && (0 === anchorOffset || 3 === node.nodeType) && (start = length + anchorOffset), node === focusNode && (0 === focusOffset || 3 === node.nodeType) && (end = length + focusOffset), 3 === node.nodeType && (length += node.nodeValue.length), null === (next = node.firstChild)) break;
|
||||
parentNode = node, node = next;
|
||||
}
|
||||
for(var next = null; node === anchorNode && (0 === anchorOffset || 3 === node.nodeType) && (start = length + anchorOffset), node === focusNode && (0 === focusOffset || 3 === node.nodeType) && (end = length + focusOffset), 3 === node.nodeType && (length += node.nodeValue.length), null !== (next = node.firstChild);)parentNode = node, node = next;
|
||||
for(;;){
|
||||
if (node === outerNode) break outer;
|
||||
if (parentNode === anchorNode && ++indexWithinAnchor === anchorOffset && (start = length), parentNode === focusNode && ++indexWithinFocus === focusOffset && (end = length), null !== (next = node.nextSibling)) break;
|
||||
|
Loading…
Reference in New Issue
Block a user