Skip to content
Myr

Small improvements

Before adoption: this commit came in with the history the project adopted, so no landing records it.

authored by Michel Weststrate · committed by Michel Weststrate · parent 746dc6f · Browse files · 4 files+24 added−34 removed
This commit

State

Before adoption: this commit came in with the history the project adopted, so no landing records it.

Diff stats

4 files+24 added−34 removed

  • other:+24 added−34 removed

4 files+24 added−34 removed

modified:src/plugins/es5.ts+1 added
35 unmodified lines
36 if (scope.patches_) {37 markChangesRecursively(scope.drafts_![0])38 }39 // This is faster when we don't care about which attributes changed.40 // TODO: should be prefixed with else!41 markChangesSweep(scope.drafts_)42 }43 // When a child draft is returned, look for changes.44 else if (
255 unmodified lines
modified:src/finalize.ts+16 added-28 removed
modified:src/immerClass.ts+5 added-6 removed
115 unmodified lines
116 if (typeof Promise !== "undefined" && result instanceof Promise) {117 return result.then(118 result => {119 scope.usePatches_(patchListener)120 return processResult(this, result, scope)120 return processResult(result, scope)121 },122 error => {123 scope.revoke_()124 throw error125 }126 )127 }128 scope.usePatches_(patchListener)129 return processResult(this, result, scope)129 return processResult(result, scope)130 } else {131 result = recipe(base)132 if (result === NOTHING) return undefined133 if (result === undefined) result = base134 maybeFreeze(this, result, true)134 maybeFreeze({immer_: this}, result, true)135 return result136 }137 }138
30 unmodified lines
169 invariant(state && state.isManual_, "First argument to `finishDraft` must be a draft returned by `createDraft`") // prettier-ignore170 invariant(!state.finalized_, "The given draft is already finalized") // prettier-ignore171 const {scope_: scope} = state172 scope.usePatches_(patchListener)173 return processResult(this, undefined, scope)173 return processResult(undefined, scope)174 }175176 /**177 * Pass true to automatically freeze all copies created by Immer.
56 unmodified lines
234 return draft235}236237export function willFinalize(238 immer: Immer,238 scope: ImmerScope,239 thing: any,240 isReplaced: boolean241) {243 if (!immer.useProxies_) willFinalizeES5(scope, thing, isReplaced)242 if (!scope.immer_.useProxies_) willFinalizeES5(scope, thing, isReplaced)243}244245export function markChanged(immer: Immer, state: ImmerState) {246 if (immer.useProxies_) {
5 unmodified lines
modified:notes.txt+2 added
14 unmodified lines
15[ ] verify performance16[ ] kill ownKeys?17[ ] kill isEnumerable?18[ ] check todos19[ ] kill marchChangesSweep recursive if possible and no perf impact20[ ] todo try immer perf on really big tree2122Import size report for immer:23┌───────────────────────┬───────────┬────────────┬───────────┐24│ (index) │ just this │ cumulative │ increment │
52 unmodified lines