FrankYang0529 commented on code in PR #19442: URL: https://github.com/apache/kafka/pull/19442#discussion_r2040530970
########## clients/src/main/java/org/apache/kafka/common/internals/PartitionStates.java: ########## @@ -138,17 +138,7 @@ private void updateSize() { } private void update(Map<TopicPartition, S> partitionToState) { - LinkedHashMap<String, List<TopicPartition>> topicToPartitions = new LinkedHashMap<>(); - for (TopicPartition tp : partitionToState.keySet()) { - List<TopicPartition> partitions = topicToPartitions.computeIfAbsent(tp.topic(), k -> new ArrayList<>()); - partitions.add(tp); - } - for (Map.Entry<String, List<TopicPartition>> entry : topicToPartitions.entrySet()) { - for (TopicPartition tp : entry.getValue()) { - S state = partitionToState.get(tp); - map.put(tp, state); - } - } + map.putAll(partitionToState); Review Comment: The `PartitionStates#update(Map<TopicPartition, S>)` is only used in `PartitionStates#set(Map<TopicPartition, S>)`. Do you think that it's more clear to move the change to `set` function directly? For example: ```java public void set(Map<TopicPartition, S> partitionToState) { map.clear(); map.putAll(partitionToState); updateSize(); } ``` -- 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: jira-unsubscr...@kafka.apache.org For queries about this service, please contact Infrastructure at: us...@infra.apache.org