We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
2 parents 75ef582 + e8af807 commit 17dd748Copy full SHA for 17dd748
topics/go/testing/benchmarks/caching/caching.go
@@ -27,26 +27,17 @@ type data struct {
27
var list *data
28
29
func init() {
30
- var last *data
31
-
32
// Create a link list with the same number of elements.
33
for row := 0; row < rows; row++ {
34
for col := 0; col < cols; col++ {
35
36
- // Create a new node and link it in.
37
- var d data
38
- if list == nil {
39
- list = &d
40
- }
41
- if last != nil {
42
- last.p = &d
43
44
- last = &d
+ // Create a new node and link it backwards.
+ list = &data{p: list}
45
46
// Add a value to all even elements.
47
if row%2 == 0 {
48
matrix[row][col] = 0xFF
49
- d.v = 0xFF
+ list.v = 0xFF
50
}
51
52
0 commit comments