cloudstack icon indicating copy to clipboard operation
cloudstack copied to clipboard

Inefficient use of a for loop

Open AsharSi opened this issue 7 months ago • 14 comments

Description

This PR improves how HTTP headers are set in the request. Replacing headers.keySet() with headers.entrySet().

This change enhances efficiency by directly accessing both the key and value in a single iteration, rather than fetching the key first and then looking up the value in the map.

Fixes: #10529

Types of changes

  • [ ] Breaking change (fix or feature that would cause existing functionality to change)
  • [ ] New feature (non-breaking change which adds functionality)
  • [ ] Bug fix (non-breaking change which fixes an issue)
  • [X] Enhancement (improves an existing feature and functionality)
  • [ ] Cleanup (Code refactoring and cleanup, that may add test cases)
  • [ ] build/CI
  • [ ] test (unit or integration test code)

Feature/Enhancement Scale or Bug Severity

Feature/Enhancement Scale

  • [ ] Major
  • [X] Minor

Bug Severity

  • [ ] BLOCKER
  • [ ] Critical
  • [ ] Major
  • [ ] Minor
  • [ ] Trivial

Screenshots (if appropriate):

How Has This Been Tested?

  • Ensured that HTTP requests are still correctly setting headers.
  • Verified that functionality remains unchanged with test cases.

How did you try to break this feature and the system with this change?

AsharSi avatar Mar 16 '25 02:03 AsharSi