-
Notifications
You must be signed in to change notification settings - Fork 10
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Change Map to a VectorMap implementation #20
Comments
I think it really depends how much slower |
@Ichoran Circe uses a normal map according to @travisbrown. Argonaut, which is scalaz's version of Circe, uses this implementation (see https://github.com/argonaut-io/argonaut/blob/master/argonaut/shared/src/main/scala/argonaut/JsonObject.scala). I will add some benchmarks and do some more work to see what the tradeoffs are. With specialization of classes the slowdown in typical cases shouldn't be that high |
For what it's worth I've been working on a branch in circe where I use |
@travisbrown Mind linking the branch? Also how do you deal with concurrency/threading issues (or I assume you just hide it internally and its not exposed). This approach also uses the |
It's still a mess and I haven't pushed it yet. But yeah, the |
We use If this library intends to be the API actually used by end-users, it would be nice if it provided that flexibility. |
@gmethvin I think the goal is going to be that we will see how |
@Ichoran I have made a seperate repo for the vector map (now called LinkedMap) implementation at https://github.com/mdedetrich/linked-map. With some very rudimentary benchmarks, it appears that |
Not 100% decided on this, here are the tradeoffs (and finally to remove confusion).
In javascript/ruby (and other mutable by default languages), the HashMap structure preserves ordering on insertion. In Scala, the immutable Map preserves insertion ordering on creation (via the usage of
.newBuilder
or by direct constructor) however if you use the various immutable copy with new value methods (i.e.+
/-
) then there is no guarantee of ordering. This means that in typical Scala use, we do maintain ordering because very few people in practise update + copy the immutable map in a way thats noticable in regards to JSON serialization.Using immutable
Map
Pros
Cons
Using
VectorMap
(see #19)Pros
Cons
Using mutable
LinkedHashMap
Pros
Cons
@Ichoran your thoughts?
The text was updated successfully, but these errors were encountered: