From ac061f2fd234214ebc598ef4cd2a007f3ace92a4 Mon Sep 17 00:00:00 2001 From: unadlib Date: Mon, 23 Sep 2024 00:00:28 +0800 Subject: [PATCH] docs(website): update --- website/blog/releases/1.0/index.md | 13 +++++++++++++ website/docs/getting-started/performance.md | 13 +++++++++++++ 2 files changed, 26 insertions(+) diff --git a/website/blog/releases/1.0/index.md b/website/blog/releases/1.0/index.md index 032249d..0eef43d 100644 --- a/website/blog/releases/1.0/index.md +++ b/website/blog/releases/1.0/index.md @@ -56,12 +56,25 @@ const state = create(baseState, (draft) => { ```ts // baseState type: { value: number }[] + +// slower 6x than Mutative const state = [ { ...baseState[0], value: i }, ...baseState.slice(1, baseState.length), ]; + +// slower 2.5x than Mutative +// const state = baseState.map((item, index) => +// index === 0 ? { ...item, value: i } : item +// ); + +// same performance as Mutative +// const state = [...baseState]; +// state[0] = { ...baseState[0], value: i }; ``` +> The actual difference depends on which spread operation syntax you use. + - Mutative ```ts diff --git a/website/docs/getting-started/performance.md b/website/docs/getting-started/performance.md index 434a288..e51ec42 100644 --- a/website/docs/getting-started/performance.md +++ b/website/docs/getting-started/performance.md @@ -44,12 +44,25 @@ const state = create(baseState, (draft) => { ```ts // baseState type: { value: number }[] + +// slower 6x than Mutative const state = [ { ...baseState[0], value: i }, ...baseState.slice(1, baseState.length), ]; + +// slower 2.5x than Mutative +// const state = baseState.map((item, index) => +// index === 0 ? { ...item, value: i } : item +// ); + +// same performance as Mutative +// const state = [...baseState]; +// state[0] = { ...baseState[0], value: i }; ``` +> The actual difference depends on which spread operation syntax you use. + - Mutative ```ts