zt52875287 commented on code in PR #19442: URL: https://github.com/apache/kafka/pull/19442#discussion_r2041284312
########## 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: Thanks for the suggestion. I've updated the code to move the logic directly into the `set` method as recommended. -- 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