LuisOsv opened a new pull request, #6453:
URL: https://github.com/apache/jmeter/pull/6453

   
   ## Description
   Caching the length/size in a variable for collections in order to avoid 
repeated calls within loops, which can slightly improve performance and 
readability.
   
   ## Motivation and Context
   While reading High Performance with Java 
([link](https://learning.oreilly.com/library/view/high-performance-with/9781835469736/B21942_03.xhtml#_idParaDest-63)),
 I came across a useful performance tip: it's recommended to cache the size of 
a collection before entering a loop, instead of calling .size() in the loop 
condition.
   
   
   Instead of:
   
   ```
   for (int i = 0; i < list.size(); i++) {
       // logic
   }
   ```
   Prefer:
   
   ```
   int size = list.size();
   for (int i = 0; i < size; i++) {
       // logic
   }
   ```
   
   ## How Has This Been Tested?
   * gradlew build was executed and 99% passed (only testInterfaces() failed)
   * gradlew createDist was executed and play with compiled .jar file locally
   
   ## Types of changes
   - Refactor foor loops
   
   


-- 
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: dev-unsubscr...@jmeter.apache.org

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

Reply via email to