Skip to content

Commit

Permalink
Merge pull request #1436 from AlexBrohshtut/spread-reduce-to-foreach
Browse files Browse the repository at this point in the history
Improve performance by replacing reduce with spread with forEach
  • Loading branch information
Nevon authored Aug 16, 2022
2 parents 599198b + e6789dd commit 1ab72f2
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/consumer/consumerGroup.js
Original file line number Diff line number Diff line change
Expand Up @@ -747,8 +747,13 @@ module.exports = class ConsumerGroup {
}

getActiveTopicPartitions() {
return this.subscriptionState
.active()
.reduce((acc, { topic, partitions }) => ({ ...acc, [topic]: new Set(partitions) }), {})
const activeSubscriptionState = this.subscriptionState.active()

const activeTopicPartitions = {}
activeSubscriptionState.forEach(({ topic, partitions }) => {
activeTopicPartitions[topic] = new Set(partitions)
})

return activeTopicPartitions
}
}

0 comments on commit 1ab72f2

Please sign in to comment.