-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Closed
Milestone
Description
problem
In the following directory: \cloudstack-main\core\src\main\java\org\apache\cloudstack\direct\download\HttpsDirectTemplateDowloader.java at line 101 we see this maybe inefficient use of a for loop:
for (String headerKey: headers.keySet()) {
req.setHeader(headerKey, headers.get(headerKey));
}
Using this for loop for the entrySet in this way causes a drop in performance because using the method .get() after iterating a keySet() it's not worth it at all.
versions
4.20
The steps to reproduce the bug
What to do about it?
We found a better implementation using this:
for (Map.Entry<String, String> entry : headers.entrySet()) {
req.setHeader(entry.getKey(), entry.getValue());
}
This avoids unnecessary searches, iterating and setting the values faster than the previous case.
Metadata
Metadata
Assignees
Labels
No labels