Skip to content

optimize perf of FromJSON of List and Vector#26

Merged
yanns merged 2 commits into
masterfrom
perf_op
May 10, 2017
Merged

optimize perf of FromJSON of List and Vector#26
yanns merged 2 commits into
masterfrom
perf_op

Conversation

@yanns

@yanns yanns commented May 9, 2017

Copy link
Copy Markdown
Contributor

@sphereio/backend please review

@cneijenhuis cneijenhuis left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

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

Maybe a comment stating that the code is the result of a performance optimization would be helpful, otherwise 👍

@agourlay

agourlay commented May 9, 2017

Copy link
Copy Markdown
Contributor

Scalaz is using foldLeft as well https://github.com/scalaz/scalaz/blob/c3133dff94ae21025014f33c1d2736bdf98e96f3/core/src/main/scala/scalaz/std/Vector.scala#L34

I do not understand where the difference comes from :(

@yanns

yanns commented May 9, 2017

Copy link
Copy Markdown
Contributor Author

The +++ for Validation needs a Semigroup. Maybe the Semigroup implementation of List and Vector is not optimal?
(like concatenating 2 lists or 2 vectors together, instead of simply adding an element)

@agourlay

agourlay commented May 9, 2017

Copy link
Copy Markdown
Contributor

Possible https://github.com/scalaz/scalaz/blob/c3133dff94ae21025014f33c1d2736bdf98e96f3/core/src/main/scala/scalaz/std/Vector.scala#L97

I guess replacing the whole Monoid append operations on immutable datastructure with a mutable collection builder with a fast append operation did the trick.

@yanns yanns merged commit 8a3579d into master May 10, 2017
@yanns yanns deleted the perf_op branch May 10, 2017 13:00
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants