Copilot commented on code in PR #2155:
URL: https://github.com/apache/pekko/pull/2155#discussion_r2326601839


##########
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) {

Review Comment:
   The property `mailbox.suspendCount` is accessed on every iteration of the 
while loop. Consider storing this value in a variable before the loop to avoid 
repeated property access.
   ```suggestion
           val suspendCount = mailbox.suspendCount
           var i = 1
           while (i <= suspendCount) {
   ```



##########
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)) {

Review Comment:
   The expression `math.min(totChunks, 10)` is evaluated on every iteration of 
the while loop. Consider storing this value in a variable before the loop to 
avoid repeated computation.



-- 
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-unsubscr...@pekko.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org


---------------------------------------------------------------------
To unsubscribe, e-mail: notifications-unsubscr...@pekko.apache.org
For additional commands, e-mail: notifications-h...@pekko.apache.org

Reply via email to