Skip to content

Commit

Permalink
Minify
Browse files Browse the repository at this point in the history
  • Loading branch information
johnsoncodehk committed Nov 12, 2024
1 parent e8db049 commit b651f2e
Showing 1 changed file with 4 additions and 65 deletions.
69 changes: 4 additions & 65 deletions packages/reactivity/src/system.ts
Original file line number Diff line number Diff line change
Expand Up @@ -35,10 +35,8 @@ export interface Link {

export enum DirtyLevels {
None,
SideEffectsOnly,
MaybeDirty,
Dirty,
Released,
}

export namespace System {
Expand Down Expand Up @@ -184,11 +182,7 @@ export namespace Dependency {
sub.depsTail!.nextDep = link
dep = sub
link = sub.subs
if ('notify' in sub) {
dirtyLevel = DirtyLevels.SideEffectsOnly
} else {
dirtyLevel = DirtyLevels.MaybeDirty
}
dirtyLevel = DirtyLevels.MaybeDirty
remainingQuantity++

continue
Expand All @@ -213,11 +207,7 @@ export namespace Dependency {
sub.depsTail!.nextDep = link
dep = sub
link = sub.subs
if ('notify' in sub) {
dirtyLevel = DirtyLevels.SideEffectsOnly
} else {
dirtyLevel = DirtyLevels.MaybeDirty
}
dirtyLevel = DirtyLevels.MaybeDirty
remainingQuantity++

continue
Expand Down Expand Up @@ -249,10 +239,6 @@ export namespace Dependency {

if (remainingQuantity === 0) {
dirtyLevel = DirtyLevels.Dirty
} else if ('notify' in dep) {
dirtyLevel = DirtyLevels.SideEffectsOnly
} else {
dirtyLevel = DirtyLevels.MaybeDirty
}

if ('notify' in prevSub) {
Expand All @@ -276,54 +262,7 @@ export namespace Dependency {
export namespace Subscriber {
const system = System

export function runInnerEffects(link: Link | undefined): void {
while (link !== undefined) {
const dep = link.dep
if ('notify' in dep) {
dep.notify()
}
link = link.nextDep
}
}

export function resolveMaybeDirty(sub: IComputed | IEffect, depth = 0): void {
let link = sub.deps

while (link !== undefined) {
const dep = link.dep
if ('update' in dep) {
const dirtyLevel = dep.dirtyLevel

if (dirtyLevel === DirtyLevels.MaybeDirty) {
if (depth >= 4) {
resolveMaybeDirtyNonRecursive(dep)
} else {
resolveMaybeDirty(dep, depth + 1)
}
if (dep.dirtyLevel === DirtyLevels.Dirty) {
dep.update()
if (sub.dirtyLevel === DirtyLevels.Dirty) {
break
}
}
} else if (dirtyLevel === DirtyLevels.Dirty) {
dep.update()
if (sub.dirtyLevel === DirtyLevels.Dirty) {
break
}
}
}
link = link.nextDep
}

if (sub.dirtyLevel === DirtyLevels.MaybeDirty) {
sub.dirtyLevel = DirtyLevels.None
}
}

export function resolveMaybeDirtyNonRecursive(
sub: IComputed | IEffect,
): void {
export function resolveMaybeDirty(sub: IComputed | IEffect): void {
let link = sub.deps
let remaining = 0

Expand Down Expand Up @@ -441,7 +380,7 @@ export namespace Subscriber {
const nextDep = link.nextDep
Link.release(link)
if (dep.subs === undefined && 'deps' in dep) {
dep.dirtyLevel = DirtyLevels.Released
dep.dirtyLevel = DirtyLevels.Dirty
if (dep.deps !== undefined) {
link = dep.deps
dep.depsTail!.nextDep = nextDep
Expand Down

0 comments on commit b651f2e

Please sign in to comment.