You are viewing a plain text version of this content. The canonical link for it is here.
Posted to commits@pekko.apache.org by he...@apache.org on 2025/09/06 07:18:18 UTC
(pekko) branch while created (now 45ed3b9019)
This is an automated email from the ASF dual-hosted git repository.
hepin pushed a change to branch while
in repository https://gitbox.apache.org/repos/asf/pekko.git
at 45ed3b9019 chore: Use while loop
This branch includes the following new commits:
new 45ed3b9019 chore: Use while loop
The 1 revisions listed above as "new" are entirely new to this
repository and will be described in separate emails. The revisions
listed as "add" were already present in the repository and have only
been added to this reference.
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org
(pekko) 01/01: chore: Use while loop
Posted by he...@apache.org.
This is an automated email from the ASF dual-hosted git repository.
hepin pushed a commit to branch while
in repository https://gitbox.apache.org/repos/asf/pekko.git
commit 45ed3b9019938f63fcd69113d0259f65eb0fd250
Author: He-Pin <he...@gmail.com>
AuthorDate: Sat Sep 6 15:18:05 2025 +0800
chore: Use while loop
---
.../org/apache/pekko/util/ByteString.scala | 4 +++-
.../org/apache/pekko/util/ByteString.scala | 5 +++--
.../scala-3/org/apache/pekko/util/ByteString.scala | 4 +++-
.../org/apache/pekko/actor/dungeon/Children.scala | 8 +++++++-
.../scala/org/apache/pekko/util/LineNumbers.scala | 22 ++++++++++++++++++----
.../apache/pekko/cluster/ddata/Replicator.scala | 4 +++-
6 files changed, 37 insertions(+), 10 deletions(-)
diff --git a/actor/src/main/scala-2.12/org/apache/pekko/util/ByteString.scala b/actor/src/main/scala-2.12/org/apache/pekko/util/ByteString.scala
index 9855a19fe3..05b60a2cad 100644
--- a/actor/src/main/scala-2.12/org/apache/pekko/util/ByteString.scala
+++ b/actor/src/main/scala-2.12/org/apache/pekko/util/ByteString.scala
@@ -523,10 +523,12 @@ object ByteString {
builder.sizeHint(nByteStrings)
- for (_ <- 0 until nByteStrings) {
+ var i = 0
+ while (i < nByteStrings) {
val bs = ByteString1.readFromInputStream(is)
builder += bs
length += bs.length
+ i += 1
}
new ByteStrings(builder.result(), length)
diff --git a/actor/src/main/scala-2.13/org/apache/pekko/util/ByteString.scala b/actor/src/main/scala-2.13/org/apache/pekko/util/ByteString.scala
index 10886bf26e..5db8d7e45c 100644
--- a/actor/src/main/scala-2.13/org/apache/pekko/util/ByteString.scala
+++ b/actor/src/main/scala-2.13/org/apache/pekko/util/ByteString.scala
@@ -531,12 +531,13 @@ object ByteString {
builder.sizeHint(nByteStrings)
- for (_ <- 0 until nByteStrings) {
+ var i = 0
+ while (i < nByteStrings) {
val bs = ByteString1.readFromInputStream(is)
builder += bs
length += bs.length
+ i += 1
}
-
new ByteStrings(builder.result(), length)
}
}
diff --git a/actor/src/main/scala-3/org/apache/pekko/util/ByteString.scala b/actor/src/main/scala-3/org/apache/pekko/util/ByteString.scala
index 8aa06c5eec..3234963538 100644
--- a/actor/src/main/scala-3/org/apache/pekko/util/ByteString.scala
+++ b/actor/src/main/scala-3/org/apache/pekko/util/ByteString.scala
@@ -532,10 +532,12 @@ object ByteString {
builder.sizeHint(nByteStrings)
- for (_ <- 0 until nByteStrings) {
+ var i = 0
+ while (i < nByteStrings) {
val bs = ByteString1.readFromInputStream(is)
builder += bs
length += bs.length
+ i += 1
}
new ByteStrings(builder.result(), length)
diff --git a/actor/src/main/scala/org/apache/pekko/actor/dungeon/Children.scala b/actor/src/main/scala/org/apache/pekko/actor/dungeon/Children.scala
index 02b6d0ed4b..8a2b79f24e 100644
--- a/actor/src/main/scala/org/apache/pekko/actor/dungeon/Children.scala
+++ b/actor/src/main/scala/org/apache/pekko/actor/dungeon/Children.scala
@@ -330,7 +330,13 @@ private[pekko] trait Children { this: ActorCell =>
throw e
}
// mailbox==null during RoutedActorCell constructor, where suspends are queued otherwise
- if (mailbox ne null) for (_ <- 1 to mailbox.suspendCount) actor.suspend()
+ if (mailbox ne null) {
+ var i = 1
+ while (i <= mailbox.suspendCount) {
+ actor.suspend()
+ i += 1
+ }
+ }
initChild(actor)
actor.start()
actor
diff --git a/actor/src/main/scala/org/apache/pekko/util/LineNumbers.scala b/actor/src/main/scala/org/apache/pekko/util/LineNumbers.scala
index 648d790ed9..5d22f9d79f 100644
--- a/actor/src/main/scala/org/apache/pekko/util/LineNumbers.scala
+++ b/actor/src/main/scala/org/apache/pekko/util/LineNumbers.scala
@@ -253,16 +253,22 @@ object LineNumbers {
private def skipInterfaceInfo(d: DataInputStream)(implicit c: Constants): Unit = {
val count = d.readUnsignedShort()
- for (_ <- 1 to count) {
+ var i = 1
+ while (i <= count) {
val intf = d.readUnsignedShort()
if (debug) println(s"LNB: implements ${c(intf)}")
+ i += 1
}
}
private def skipFields(d: DataInputStream)(implicit c: Constants): Unit = {
val count = d.readUnsignedShort()
if (debug) println(s"LNB: reading $count fields:")
- for (_ <- 1 to count) skipMethodOrField(d)
+ var i = 1
+ while (i <= count) {
+ skipMethodOrField(d)
+ i += 1
+ }
}
private def skipMethodOrField(d: DataInputStream)(implicit c: Constants): Unit = {
@@ -270,7 +276,11 @@ object LineNumbers {
val name = d.readUnsignedShort() // name
skip(d, 2) // signature
val attributes = d.readUnsignedShort()
- for (_ <- 1 to attributes) skipAttribute(d)
+ var i = 1
+ while (i <= attributes) {
+ skipAttribute(d)
+ i += 1
+ }
if (debug) println(s"LNB: ${c(name)} ($attributes attributes)")
}
@@ -295,7 +305,11 @@ object LineNumbers {
}
} else {
if (debug) println(s"LNB: (skipped)")
- for (_ <- 1 to count) skipMethodOrField(d)
+ var i = 1
+ while (i <= count) {
+ skipMethodOrField(d)
+ i += 1
+ }
None
}
}
diff --git a/distributed-data/src/main/scala/org/apache/pekko/cluster/ddata/Replicator.scala b/distributed-data/src/main/scala/org/apache/pekko/cluster/ddata/Replicator.scala
index 39749f1687..a89aa22dd1 100644
--- a/distributed-data/src/main/scala/org/apache/pekko/cluster/ddata/Replicator.scala
+++ b/distributed-data/src/main/scala/org/apache/pekko/cluster/ddata/Replicator.scala
@@ -1971,7 +1971,8 @@ final class Replicator(settings: ReplicatorSettings) extends Actor with ActorLog
to ! status
} else {
val totChunks = dataEntries.size / maxDeltaElements
- for (_ <- 1 to math.min(totChunks, 10)) {
+ var i = 1
+ while (i <= math.min(totChunks, 10)) {
if (totChunks == statusTotChunks)
statusCount += 1
else {
@@ -1983,6 +1984,7 @@ final class Replicator(settings: ReplicatorSettings) extends Actor with ActorLog
case (key, (_, _)) if math.abs(key.hashCode % totChunks) == chunk => (key, getDigest(key))
}, chunk, totChunks, toSystemUid, selfFromSystemUid)
to ! status
+ i += 1
}
}
}
---------------------------------------------------------------------
To unsubscribe, e-mail: commits-unsubscribe@pekko.apache.org
For additional commands, e-mail: commits-help@pekko.apache.org