mirror of
https://github.com/marko-js/marko.git
synced 2025-12-08 19:26:05 +00:00
perf: reorganize pending scope logic for better minification
This commit is contained in:
parent
1fd3bae774
commit
eda81ee80a
36
.sizes.json
36
.sizes.json
@ -7,8 +7,8 @@
|
||||
{
|
||||
"name": "*",
|
||||
"total": {
|
||||
"min": 19177,
|
||||
"brotli": 7273
|
||||
"min": 19158,
|
||||
"brotli": 7262
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -18,12 +18,12 @@
|
||||
"brotli": 145
|
||||
},
|
||||
"runtime": {
|
||||
"min": 3944,
|
||||
"brotli": 1736
|
||||
"min": 3925,
|
||||
"brotli": 1728
|
||||
},
|
||||
"total": {
|
||||
"min": 4134,
|
||||
"brotli": 1881
|
||||
"min": 4115,
|
||||
"brotli": 1873
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -33,12 +33,12 @@
|
||||
"brotli": 100
|
||||
},
|
||||
"runtime": {
|
||||
"min": 2982,
|
||||
"brotli": 1456
|
||||
"min": 2967,
|
||||
"brotli": 1448
|
||||
},
|
||||
"total": {
|
||||
"min": 3094,
|
||||
"brotli": 1556
|
||||
"min": 3079,
|
||||
"brotli": 1548
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -48,12 +48,12 @@
|
||||
"brotli": 461
|
||||
},
|
||||
"runtime": {
|
||||
"min": 7028,
|
||||
"brotli": 3013
|
||||
"min": 7009,
|
||||
"brotli": 3007
|
||||
},
|
||||
"total": {
|
||||
"min": 7949,
|
||||
"brotli": 3474
|
||||
"min": 7930,
|
||||
"brotli": 3468
|
||||
}
|
||||
},
|
||||
{
|
||||
@ -63,12 +63,12 @@
|
||||
"brotli": 128
|
||||
},
|
||||
"runtime": {
|
||||
"min": 3148,
|
||||
"brotli": 1511
|
||||
"min": 3133,
|
||||
"brotli": 1508
|
||||
},
|
||||
"total": {
|
||||
"min": 3293,
|
||||
"brotli": 1639
|
||||
"min": 3278,
|
||||
"brotli": 1636
|
||||
}
|
||||
}
|
||||
]
|
||||
|
||||
@ -1,4 +1,4 @@
|
||||
// size: 19177 (min) 7273 (brotli)
|
||||
// size: 19158 (min) 7262 (brotli)
|
||||
var empty = [],
|
||||
rest = Symbol();
|
||||
function attrTag(attrs2) {
|
||||
@ -775,7 +775,6 @@ function toInsertNode(startNode, endNode) {
|
||||
}
|
||||
return parent;
|
||||
}
|
||||
var pendingScopes = [];
|
||||
function createScope($global, closestBranch) {
|
||||
let scope = { m: $global.o++, p: 1, k: closestBranch, $global: $global };
|
||||
return pendingScopes.push(scope), scope;
|
||||
@ -1597,6 +1596,7 @@ var rendering,
|
||||
caughtError = new WeakSet(),
|
||||
placeholderShown = new WeakSet(),
|
||||
pendingEffects = [],
|
||||
pendingScopes = [],
|
||||
scopeKeyOffset = 1e3;
|
||||
function queueRender(scope, signal, signalKey, value2, scopeKey = scope.m) {
|
||||
let key = scopeKey * scopeKeyOffset + signalKey,
|
||||
@ -1674,10 +1674,8 @@ function runRenders() {
|
||||
}
|
||||
render.D.k?.A || runRender(render);
|
||||
}
|
||||
!(function () {
|
||||
for (let scope of pendingScopes) scope.p = 0;
|
||||
pendingScopes = [];
|
||||
})();
|
||||
for (let scope of pendingScopes) scope.p = 0;
|
||||
pendingScopes = [];
|
||||
}
|
||||
var runRender = (render) => render.L(render.D, render.I),
|
||||
enableCatch = () => {
|
||||
|
||||
@ -1,6 +1,5 @@
|
||||
import type { BranchScope, Scope } from "../common/types";
|
||||
import { renderCatch } from "./control-flow";
|
||||
import { finishPendingScopes } from "./scope";
|
||||
import type { Signal } from "./signals";
|
||||
|
||||
type ExecFn<S extends Scope = Scope> = (scope: S, arg?: any) => void;
|
||||
@ -16,6 +15,7 @@ let pendingRendersLookup = new Map<number, PendingRender>();
|
||||
export const caughtError = new WeakSet<unknown[]>();
|
||||
export const placeholderShown = new WeakSet<unknown[]>();
|
||||
export let pendingEffects: unknown[] = [];
|
||||
export let pendingScopes: Scope[] = [];
|
||||
export let rendering: undefined | 0 | 1;
|
||||
|
||||
const scopeKeyOffset = 1e3;
|
||||
@ -139,7 +139,11 @@ function runRenders() {
|
||||
}
|
||||
}
|
||||
|
||||
finishPendingScopes();
|
||||
for (const scope of pendingScopes) {
|
||||
scope.___creating = 0;
|
||||
}
|
||||
|
||||
pendingScopes = [];
|
||||
}
|
||||
|
||||
let runRender = (render: PendingRender) =>
|
||||
|
||||
@ -1,7 +1,6 @@
|
||||
import type { BranchScope, Scope } from "../common/types";
|
||||
import { insertChildNodes, removeChildNodes } from "./dom";
|
||||
|
||||
let pendingScopes: Scope[] = [];
|
||||
import { pendingScopes } from "./queue";
|
||||
|
||||
export function createScope(
|
||||
$global: Scope["$global"],
|
||||
@ -15,7 +14,6 @@ export function createScope(
|
||||
} as Scope;
|
||||
|
||||
pendingScopes.push(scope);
|
||||
|
||||
return scope;
|
||||
}
|
||||
|
||||
@ -23,14 +21,6 @@ export function skipScope(scope: Scope) {
|
||||
return scope.$global.___nextScopeId++;
|
||||
}
|
||||
|
||||
export function finishPendingScopes() {
|
||||
for (const scope of pendingScopes) {
|
||||
scope.___creating = 0;
|
||||
}
|
||||
|
||||
pendingScopes = [];
|
||||
}
|
||||
|
||||
export function findBranchWithKey(
|
||||
scope: Scope,
|
||||
key: string,
|
||||
|
||||
Loading…
x
Reference in New Issue
Block a user