scala-library-next icon indicating copy to clipboard operation
scala-library-next copied to clipboard

Override LongMap updateWith, add transformValue and transformValueDefault

Open Adam-Vandervorst opened this issue 1 year ago • 1 comments

LongMap's is a performance oriented addition, yet updating it requires two lookups because the updateWith function is delegated to MapOps.

Furthermore, updateWith deals with the 'XT' Option[A] => Option[A] remap function, which discourages otherwise good uses of the function, and degrades performance. Therefore I propose to add transformValue(key: K)(transformation: V => V) and transformValueDefault(key: K)(default: => V)(transformation: V => V) that deal with the most common usecases.

Adam-Vandervorst avatar Sep 27 '22 11:09 Adam-Vandervorst

I think it’s possible to override updateWith already in Scala 2.13. Would you be interested in submitting a PR?

About the other suggestions, yes they would have to go into scala-library-next.

julienrf avatar Oct 19 '22 08:10 julienrf