feat: use external package for ordered maps #1797
Open
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR completely removes and replaces our native
omap
package with a 3rd-party one. There are a few reasons for this change:This PR also makes way for the use of iterators (which we cannot use until we bump our minimum version to 1.23). A working PoC of this is available in #1798.
This also has a direct knock-on effect to #1605 - though falls short of fixing it. @trim21 has #1701 open to address this. I'm afraid that this will need rethinking as the fix was in our custom
omap
implementation previously. Now that we have a bit more separation, we will need to bring the fixes into our implementations ofTasks
,Includes
andVars
. This falls inline with the thoughts of the creator of theorderedmap
package we are moving to. That is, concurrency should be fixed by the implementation, not the ordered map itself. This is similar to how a Gomap
does not have built-in concurrency protection.As for the code, I chose elliotchance/orderedmap for a couple of reason over other packages:
O(1)
overSet
,Get
,Delete
andLen
operations.I have opened a couple of issues on the project that would ease our integration. However, neither of there are dealbreakers - Just nice-to-have:
One additional note. We now use custom unmarshalling on all implementations of ordered maps (previously this was only on
Includes
). This is because theorderedmap
package does not natively support is. It may do in the future, but this doesn't matter to us as the custom unmarshal functions actually tidy up some of our code. Generally speaking, I have tried to tidy up and make all the implementations of ordered maps in our code a bit more consistent.