Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4390681

Browse files
5.2 []struct{}
1 parent 2f3da40 commit 4390681

File tree

2 files changed

+10
-5
lines changed

2 files changed

+10
-5
lines changed

‎performance_rule/datastructure/iterate_struct_pointer_test.go‎

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -2,16 +2,16 @@ package datastructure
22

33
import "testing"
44

5-
type Item struct {
5+
type Item1 struct {
66
id int
77
val [1024]byte
88
}
99

10-
// genItems 生成指定长度 []*Item 切片
11-
func genItems(n int) []*Item {
12-
items := make([]*Item, 0, n)
10+
// genItems 生成指定长度 []*Item1 切片
11+
func genItems(n int) []*Item1 {
12+
items := make([]*Item1, 0, n)
1313
for i := 0; i < n; i++ {
14-
items = append(items, &Item{id: i})
14+
items = append(items, &Item1{id: i})
1515
}
1616
return items
1717
}

‎performance_rule/datastructure/iterate_struct_test.go‎

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,11 @@ package datastructure
22

33
import "testing"
44

5+
type Item struct {
6+
id int
7+
val [1024]byte
8+
}
9+
510
func BenchmarkIndexStructSlice(b *testing.B) {
611
var items [1024]Item
712
for i := 0; i < b.N; i++ {

0 commit comments

Comments
(0)

AltStyle によって変換されたページ (->オリジナル) /