Skip to content

Commit

Permalink
Improve performance by replacing reduce with spread with forEach
Browse files Browse the repository at this point in the history
  • Loading branch information
AlexBrohshtut committed Aug 15, 2022
1 parent 599198b commit e6789dd
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 e6789dd

Please sign in to comment.