Skip to content

Commit

Permalink
Improve some loops (use copy, style fix)
Browse files Browse the repository at this point in the history
  • Loading branch information
stek29 committed Dec 25, 2019
1 parent cbcedf0 commit 6cf54c1
Show file tree
Hide file tree
Showing 3 changed files with 5 additions and 9 deletions.
2 changes: 1 addition & 1 deletion bot.go
Original file line number Diff line number Diff line change
Expand Up @@ -621,7 +621,7 @@ func (b *Bot) SendAlbum(to Recipient, a Album, options ...interface{}) ([]Messag
return nil, errors.Errorf("api error: %s", resp.Description)
}

for attachName, _ := range files {
for attachName := range files {
i, _ := strconv.Atoi(attachName)

var newID string
Expand Down
8 changes: 2 additions & 6 deletions options.go
Original file line number Diff line number Diff line change
Expand Up @@ -107,17 +107,13 @@ func (og *ReplyMarkup) copy() *ReplyMarkup {
cp.ReplyKeyboard = make([][]ReplyButton, len(og.ReplyKeyboard))
for i, row := range og.ReplyKeyboard {
cp.ReplyKeyboard[i] = make([]ReplyButton, len(row))
for j, btn := range row {
cp.ReplyKeyboard[i][j] = btn
}
copy(cp.ReplyKeyboard[i], row)
}

cp.InlineKeyboard = make([][]InlineButton, len(og.InlineKeyboard))
for i, row := range og.InlineKeyboard {
cp.InlineKeyboard[i] = make([]InlineButton, len(row))
for j, btn := range row {
cp.InlineKeyboard[i][j] = btn
}
copy(cp.InlineKeyboard[i], row)
}

return &cp
Expand Down
4 changes: 2 additions & 2 deletions util.go
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ func processButtons(keys [][]InlineButton) {
return
}

for i, _ := range keys {
for j, _ := range keys[i] {
for i := range keys {
for j := range keys[i] {
key := &keys[i][j]
if key.Unique != "" {
// Format: "\f<callback_name>|<data>"
Expand Down

0 comments on commit 6cf54c1

Please sign in to comment.