Skip to content

Commit

Permalink
performance,typo: prealloc slice for performance and fix typo (#816)
Browse files Browse the repository at this point in the history
* prealloc for performance

* mispell
  • Loading branch information
xiekeyi98 authored Jan 21, 2022
1 parent 5882460 commit d81d37a
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 5 deletions.
2 changes: 1 addition & 1 deletion consumergroup.go
Original file line number Diff line number Diff line change
Expand Up @@ -326,7 +326,7 @@ type Generation struct {
// between Start and close. lock protects all of them. done is closed
// when the generation is ending in order to signal that the generation
// should start self-desructing. closed protects against double-closing
// the done chan. routines is a count of runing go routines that have been
// the done chan. routines is a count of running go routines that have been
// launched by Start. joined will be closed by the last go routine to exit.
lock sync.Mutex
done chan struct{}
Expand Down
6 changes: 3 additions & 3 deletions createtopics.go
Original file line number Diff line number Diff line change
Expand Up @@ -209,13 +209,13 @@ func (t *TopicConfig) configs() []createtopics.RequestConfig {
}

func (t TopicConfig) toCreateTopicsRequestV0Topic() createTopicsRequestV0Topic {
var requestV0ReplicaAssignments []createTopicsRequestV0ReplicaAssignment
requestV0ReplicaAssignments := make([]createTopicsRequestV0ReplicaAssignment, 0, len(t.ReplicaAssignments))
for _, a := range t.ReplicaAssignments {
requestV0ReplicaAssignments = append(
requestV0ReplicaAssignments,
a.toCreateTopicsRequestV0ReplicaAssignment())
}
var requestV0ConfigEntries []createTopicsRequestV0ConfigEntry
requestV0ConfigEntries := make([]createTopicsRequestV0ConfigEntry, 0, len(t.ConfigEntries))
for _, c := range t.ConfigEntries {
requestV0ConfigEntries = append(
requestV0ConfigEntries,
Expand Down Expand Up @@ -377,7 +377,7 @@ func (c *Conn) createTopics(request createTopicsRequestV0) (createTopicsResponse
// operational semantics. In other words, if CreateTopics is invoked with a
// configuration for an existing topic, it will have no effect.
func (c *Conn) CreateTopics(topics ...TopicConfig) error {
var requestV0Topics []createTopicsRequestV0Topic
requestV0Topics := make([]createTopicsRequestV0Topic, 0, len(topics))
for _, t := range topics {
requestV0Topics = append(
requestV0Topics,
Expand Down
2 changes: 1 addition & 1 deletion reader_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -1552,7 +1552,7 @@ func TestConsumerGroupWithGroupTopicsMultple(t *testing.T) {

time.Sleep(time.Second)

var msgs []Message
msgs := make([]Message, 0, len(conf.GroupTopics))
for _, topic := range conf.GroupTopics {
msgs = append(msgs, Message{Topic: topic})
}
Expand Down

0 comments on commit d81d37a

Please sign in to comment.