liangjh98 commented on code in PR #6191:
URL: https://github.com/apache/shenyu/pull/6191#discussion_r2384453927
##########
shenyu-plugin/shenyu-plugin-logging/shenyu-plugin-logging-common/src/main/java/org/apache/shenyu/plugin/logging/common/utils/LogCollectUtils.java:
##########
@@ -17,21 +17,21 @@
package org.apache.shenyu.plugin.logging.common.utils;
+import com.google.common.collect.Sets;
import org.apache.shenyu.common.utils.JsonUtils;
import org.springframework.http.HttpHeaders;
-import java.util.Arrays;
-import java.util.List;
import java.util.Map;
import java.util.Optional;
+import java.util.Set;
import java.util.stream.Collectors;
/**
* log collect utils.
*/
public class LogCollectUtils {
- private static final List<String> BINARY_TYPE_LIST =
Arrays.asList("image", "multipart", "cbor",
+ private static final Set<String> BINARY_TYPE_LIST =
Sets.newHashSet("image", "multipart", "cbor",
Review Comment:
The Set data structure has a time complexity of O(1) for element lookup,
while List has O(n). Since the code frequently checks whether
contentType.getType() and contentType.getSubtype() exist in BINARY_TYPE_LIST,
using Set can significantly improve performance.
--
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: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]