Skip to content

Commit 8dd09a6

Browse files
authored
Merge pull request #1853 from testwill/replace-loop
chore: slice replace loop
2 parents 05e4a9d + 183a5c7 commit 8dd09a6

File tree

5 files changed

+7
-21
lines changed

5 files changed

+7
-21
lines changed

memory/database.go

Lines changed: 3 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -251,9 +251,7 @@ func (d *BaseDatabase) RenameTable(ctx *sql.Context, oldName, newName string) er
251251

252252
func (d *BaseDatabase) GetTriggers(ctx *sql.Context) ([]sql.TriggerDefinition, error) {
253253
var triggers []sql.TriggerDefinition
254-
for _, def := range d.triggers {
255-
triggers = append(triggers, def)
256-
}
254+
triggers = append(triggers, d.triggers...)
257255
return triggers, nil
258256
}
259257

@@ -291,9 +289,7 @@ func (d *BaseDatabase) GetStoredProcedure(ctx *sql.Context, name string) (sql.St
291289
// GetStoredProcedures implements sql.StoredProcedureDatabase
292290
func (d *BaseDatabase) GetStoredProcedures(ctx *sql.Context) ([]sql.StoredProcedureDetails, error) {
293291
var spds []sql.StoredProcedureDetails
294-
for _, spd := range d.storedProcedures {
295-
spds = append(spds, spd)
296-
}
292+
spds = append(spds, d.storedProcedures...)
297293
return spds, nil
298294
}
299295

@@ -340,9 +336,7 @@ func (d *BaseDatabase) GetEvent(ctx *sql.Context, name string) (sql.EventDefinit
340336
// GetEvents implements sql.EventDatabase
341337
func (d *BaseDatabase) GetEvents(ctx *sql.Context) ([]sql.EventDefinition, error) {
342338
var eds []sql.EventDefinition
343-
for _, ed := range d.events {
344-
eds = append(eds, ed)
345-
}
339+
eds = append(eds, d.events...)
346340
return eds, nil
347341
}
348342

sql/in_mem_table/data.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -272,9 +272,7 @@ func (data *Data) ToSlice(ctx *sql.Context) []Entry {
272272
var entries []Entry
273273
for _, indexedData := range data.data {
274274
for _, ourEntries := range indexedData {
275-
for _, entry := range ourEntries {
276-
entries = append(entries, entry)
277-
}
275+
entries = append(entries, ourEntries...)
278276
}
279277
break
280278
}

sql/information_schema/information_schema.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2806,9 +2806,7 @@ func viewsInDatabase(ctx *Context, db Database) ([]ViewDefinition, error) {
28062806
return nil, err
28072807
}
28082808

2809-
for _, view := range dbViews {
2810-
views = append(views, view)
2811-
}
2809+
views = append(views, dbViews...)
28122810
}
28132811

28142812
for _, view := range ctx.GetViewRegistry().ViewsInDatabase(dbName) {

sql/plan/indexed_table_access.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -245,9 +245,7 @@ func (i *IndexedTableAccess) String() string {
245245

246246
func formatIndexDecoratorString(idx sql.Index) string {
247247
var expStrs []string
248-
for _, e := range idx.Expressions() {
249-
expStrs = append(expStrs, e)
250-
}
248+
expStrs = append(expStrs, idx.Expressions()...)
251249
return fmt.Sprintf("[%s]", strings.Join(expStrs, ","))
252250
}
253251

sql/rowexec/window_test.go

Lines changed: 1 addition & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -77,9 +77,7 @@ func TestWindowPlanToIter(t *testing.T) {
7777
require.Equal(t, len(outputOrdinals), 3)
7878
accOrdinals := make([]int, 0)
7979
for _, p := range outputOrdinals {
80-
for _, v := range p {
81-
accOrdinals = append(accOrdinals, v)
82-
}
80+
accOrdinals = append(accOrdinals, p...)
8381
}
8482
require.ElementsMatch(t, accOrdinals, []int{0, 1, 2, 3})
8583

0 commit comments

Comments
 (0)