Skip to content
This repository has been archived by the owner on Nov 29, 2023. It is now read-only.

use map instead of object #985

Merged
merged 3 commits into from
Aug 4, 2023
Merged

use map instead of object #985

merged 3 commits into from
Aug 4, 2023

Conversation

delcroip
Copy link
Contributor

it seems that maps are faster, as this is assessed many time small speed improvement can have good effect

https://www.zhenghao.io/posts/object-vs-map

I cannot test (no set up working) but this should not require too many change to work

delcroip and others added 3 commits July 11, 2023 22:48
it seems that maps are faster, as this is assessed many time small speed improvement can have good effect

https://www.zhenghao.io/posts/object-vs-map
Copy link
Contributor

@eyelidlessness eyelidlessness left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks!

I don't expect this to have a significant performance impact in itself (though more broadly adopting Map may, in aggregate!). Even apart from performance, though, I've generally been wanting to move towards using:

  • Map for "bag of stuff" key-value data types
  • objects for data of a statically known type/shape (e.g. with explicitly known keys)

This is a good first step in that directions, and it's a good opportunity to put the intent into words.

The only thing that felt potentially risky about this change in particular is the possibility that FormModel#convertedExpressions may be accessed elsewhere, but I do not see any such access.

I want to more thoroughly evaluate where we're using instance properties this way, and whether they can be either converted to local (e.g. to module or other more narrowly scoped) variables, better encapsulated or at least documented as private. This is theoretically a "breaking" change, in that it modifies an accessible API type, but I don't think that technicality applies for real world usage in this case. I just want to make note that this was a consideration in review.

@eyelidlessness eyelidlessness merged commit f37eed2 into enketo:master Aug 4, 2023
2 checks passed
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants