From ba69f7e4be5c40cd90a914a29e113f36cd7f3833 Mon Sep 17 00:00:00 2001 From: mdgriffith Date: Fri, 21 Aug 2020 09:54:23 -0400 Subject: [PATCH] update notes on the approach using the spread operator for inline updating --- notes/transformations.md | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/notes/transformations.md b/notes/transformations.md index f91658c..f9402ca 100644 --- a/notes/transformations.md +++ b/notes/transformations.md @@ -250,13 +250,19 @@ with Object.assign({}, old, newFields) ``` +Or we can use the spread operator inline: + +``` +{...old, ...new} +``` + ## Result Summary - Not included in elm-optimize tool - Again, all of these tricks rely on either the spread operator or `Object.assign`, both of which are not supported in IE. -- The most promising approach was inlining the call completely with `Object.assign`. - - Gave a `366%` boost in chrome! - - And caused firefox to reduce performance by 50% :sweat_smile: +- The most promising approach was inlining the call completely with `{...old, field: newValue}`. + - Gave a `501%` boost in chrome! + - And caused safari to reduce performance by 50% :sweat_smile: Simply creating a new record and copying each field manually is significantly faster than and of these transformations.(~9x in chrome, and ~6.5x in firefox). You can do this directly in elm.