Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

performance,typo: prealloc slice for performance and fix typo #816

Merged
merged 2 commits into from
Jan 21, 2022
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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