Fabulous-new
Fabulous-new copied to clipboard
[Performance] Avoid dynamic dispatch for Convert / ConvertValue in AttributeDefinition
One thing I was thinking about if we can make convert functions optional (ValueOption
). My understanding that it is id
function mist of the time. If that is true, skipping calling it with checking for ValueSome
is probably worth it in terms of perf.
BUT! it is probably going to be tricky to type properly, given that then we will have to convert 'modelType -> 'valueType
.
So maybe a union can be a solution there. just a sketch:
type ScalarAttributeDefinition<'inputType, 'modelType, 'valueType> =
| NoConverters of .... // 'inputType = 'modelType = 'valueType, are all the same
| JustModelConverted of ... // 'inputType <> 'modelType , 'valueType ='modelType
| JustValueConverter of ... // 'inputType = 'modelType , 'valueType <> 'modelType
| ModelAndValueConverters of ... // 'inputType <> 'modelType <> 'valueType, are all different
Feels very clunky but possible worth considering
Originally posted by @twop in https://github.com/TimLariviere/Fabulous-new/pull/33#discussion_r783669046