kezhenxu94 commented on a change in pull request #5612:
URL: https://github.com/apache/skywalking/pull/5612#discussion_r500291987
##########
File path:
apm-sniffer/optional-plugins/customize-enhance-plugin/src/main/java/org/apache/skywalking/apm/plugin/customize/interceptor/BaseInterceptorMethods.java
##########
@@ -56,15 +56,14 @@ void beforeMethod(Method method, Object[] allArguments) {
}
}
if (tags != null && !tags.isEmpty()) {
- for (String key : tags.keySet()) {
- String expression = tags.get(key);
- spanTags.put(key,
CustomizeExpression.parseExpression(expression, context));
+ for (Map.Entry<String, String> expression:
tags.entrySet()) {
+ spanTags.put(expression.getKey(),
CustomizeExpression.parseExpression(expression.getValue(), context));
}
}
if (logs != null && !logs.isEmpty()) {
- for (String key : logs.keySet()) {
- String expression = logs.get(key);
- spanLogs.put(key,
CustomizeExpression.parseExpression(expression, context));
+ for (Map.Entry<String, String> entries : logs.entrySet()) {
+ String expression = logs.get(entries.getKey());
Review comment:
Well, I'm later for just a second 🤣 but this doesn't fix what you said
in the comment
> Accessing a value using a key that was retrieved from a keySet iterator.
It is more efficient to use an iterator on the entrySet of the map, avoiding
the extra HashMap.get(key) lookup.
"avoiding the extra HashMap.get(key) lookup.", you are still looking up with
the key
----------------------------------------------------------------
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.
For queries about this service, please contact Infrastructure at:
[email protected]