You are viewing a plain text version of this content. The canonical link for it is here.
Posted to notifications@pekko.apache.org by "He-Pin (via GitHub)" <gi...@apache.org> on 2023/08/27 14:10:57 UTC
[GitHub] [incubator-pekko] He-Pin opened a new pull request, #591: =str Make use of statefulMap to implement zipWithIndex.
He-Pin opened a new pull request, #591:
URL: https://github.com/apache/incubator-pekko/pull/591
Motivation:
Make code more simpler.
Result:
Simpler code and no performance regression.
```
Jmh/run -i 3 -wi 3 -f1 -t1 .*ZipWithIndexBenchmark.*
[info] Benchmark Mode Cnt Score Error Units
[info] ZipWithIndexBenchmark.benchNewZipWithIndex thrpt 3 6501714129.146 锟斤拷 4044285303.660 ops/s
[info] ZipWithIndexBenchmark.benchOldZipWithIndex thrpt 3 6146967182.338 锟斤拷 801852805.114 ops/s
```
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
[GitHub] [incubator-pekko] He-Pin merged pull request #591: =str Make use of statefulMap to implement zipWithIndex.
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin merged PR #591:
URL: https://github.com/apache/incubator-pekko/pull/591
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
[GitHub] [incubator-pekko] He-Pin commented on pull request #591: =str Make use of statefulMap to implement zipWithIndex.
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on PR #591:
URL: https://github.com/apache/incubator-pekko/pull/591#issuecomment-1695405291
I think this one is ready.
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org
[GitHub] [incubator-pekko] He-Pin commented on a diff in pull request #591: =str Make use of statefulMap to implement zipWithIndex.
Posted by "He-Pin (via GitHub)" <gi...@apache.org>.
He-Pin commented on code in PR #591:
URL: https://github.com/apache/incubator-pekko/pull/591#discussion_r1307169385
##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala:
##########
@@ -2881,16 +2881,9 @@ trait FlowOps[+Out, +Mat] {
*
* '''Cancels when''' downstream cancels
*/
- def zipWithIndex: Repr[(Out, Long)] = {
- statefulMapConcat[(Out, Long)] { () =>
- var index: Long = 0L
- elem => {
- val zipped = (elem, index)
- index += 1
- immutable.Iterable[(Out, Long)](zipped)
- }
- }
- }
+ def zipWithIndex: Repr[(Out, Long)] = statefulMap(() => 0L)({
+ case (index, out) => (index + 1L, (out, index))
+ }, _ => None).withAttributes(DefaultAttributes.zipWithIndex)
Review Comment:
Add the `name`
##########
stream/src/main/scala/org/apache/pekko/stream/scaladsl/Flow.scala:
##########
@@ -2881,16 +2881,9 @@ trait FlowOps[+Out, +Mat] {
*
* '''Cancels when''' downstream cancels
*/
- def zipWithIndex: Repr[(Out, Long)] = {
- statefulMapConcat[(Out, Long)] { () =>
- var index: Long = 0L
- elem => {
- val zipped = (elem, index)
- index += 1
- immutable.Iterable[(Out, Long)](zipped)
- }
- }
- }
+ def zipWithIndex: Repr[(Out, Long)] = statefulMap(() => 0L)({
+ case (index, out) => (index + 1L, (out, index))
+ }, _ => None).withAttributes(DefaultAttributes.zipWithIndex)
Review Comment:
Added the `name`
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For queries about this service, please contact Infrastructure at:
users@infra.apache.org
---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscribe@pekko.apache.org
For additional commands, e-mail: notifications-help@pekko.apache.org