Skip to content
This repository has been archived by the owner on Apr 2, 2022. It is now read-only.

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

Open
TimLariviere opened this issue Jan 13, 2022 · 0 comments

Comments

@TimLariviere
Copy link
Owner

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 #33 (comment)

@TimLariviere TimLariviere changed the title [Optimization] Avoid dynamic dispatch for Convert / ConvertValue in AttributeDefinition [Performance] Avoid dynamic dispatch for Convert / ConvertValue in AttributeDefinition Jan 14, 2022
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant