Fabulous-new icon indicating copy to clipboard operation
Fabulous-new copied to clipboard

[Performance] Avoid dynamic dispatch for Convert / ConvertValue in AttributeDefinition

Open TimLariviere opened this issue 2 years ago • 0 comments

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

TimLariviere avatar Jan 13 '22 21:01 TimLariviere