chore: Use while loop (#2155)
This commit is contained in:
parent
6e436584ac
commit
c708891504
6 changed files with 39 additions and 10 deletions
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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)
|
||||
|
|
|
|||
|
|
@ -330,7 +330,14 @@ 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) {
|
||||
val suspendCount = mailbox.suspendCount
|
||||
var i = 1
|
||||
while (i <= suspendCount) {
|
||||
actor.suspend()
|
||||
i += 1
|
||||
}
|
||||
}
|
||||
initChild(actor)
|
||||
actor.start()
|
||||
actor
|
||||
|
|
|
|||
|
|
@ -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
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -1971,7 +1971,9 @@ 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
|
||||
val maxLoop = math.min(totChunks, 10)
|
||||
while (i <= maxLoop) {
|
||||
if (totChunks == statusTotChunks)
|
||||
statusCount += 1
|
||||
else {
|
||||
|
|
@ -1983,6 +1985,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
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue