Skip to content

Commit e4f2d72

Browse files
authored
Merge pull request #8 from regeda/dont_add_to_grid
Don't add a value to the grid
2 parents e5a210b + 1700fd3 commit e4f2d72

File tree

4 files changed

+7
-19
lines changed

4 files changed

+7
-19
lines changed

Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
.PHONY: gen-proto gen-fbs gen-lexer test bench bench-report
1+
.PHONY: gen-proto gen-fbs gen-lexer test bench bench-report escape-analysis
22

33
default: test
44

@@ -22,3 +22,5 @@ bench: test
2222

2323
bench-report: bench
2424
@go tool pprof -web cpu.out
25+
26+
escape-analysis: ; @go test -gcflags="-m" ./...

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -170,5 +170,5 @@ equals("foo,bar,baz", join(",", ["foo", "bar", "baz"]))
170170
```
171171
cpu: Intel(R) Core(TM) i5-8259U CPU @ 2.30GHz
172172
BenchmarkExec
173-
BenchmarkExec-8 1432002 833.2 ns/op 0 B/op 0 allocs/op
173+
BenchmarkExec-8 1508277 798.5 ns/op 0 B/op 0 allocs/op
174174
```

memory/grid.go

Lines changed: 0 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -25,10 +25,3 @@ func (g *grid) alloc(n uint32) []Addr {
2525
func (g *grid) reset() {
2626
g.off = 0
2727
}
28-
29-
func (g *grid) add(a Addr) Addr {
30-
g.grow(1)
31-
g.buf[g.off] = a
32-
g.off++
33-
return a
34-
}

memory/memory.go

Lines changed: 3 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -45,14 +45,7 @@ func (b *Memory) Reset() {
4545

4646
func (b *Memory) alloc(t Type, size uint32) Addr {
4747
buf := b.h.alloc(size)
48-
return b.allocAddr(t, buf)
49-
}
50-
51-
func (b *Memory) allocAddr(t Type, dat []byte) Addr {
52-
return b.g.add(Addr{
53-
typ: t,
54-
dat: dat,
55-
})
48+
return NewAddr(t, buf...)
5649
}
5750

5851
func (b *Memory) Alloc(in interface{}) (Addr, error) {
@@ -86,7 +79,7 @@ func (b *Memory) Alloc(in interface{}) (Addr, error) {
8679
}
8780

8881
func (b *Memory) AllocBytesAddr(dat []byte) Addr {
89-
return b.allocAddr(TypeBytes, dat)
82+
return NewAddr(TypeBytes, dat...)
9083
}
9184

9285
func (b *Memory) AllocBytes(size uint32) Addr {
@@ -103,7 +96,7 @@ func (b *Memory) AllocInt64(v int64) Addr {
10396
}
10497

10598
func (b *Memory) AllocVector(size uint32) Addr {
106-
addr := b.allocAddr(TypeVector, nil)
99+
addr := NewAddr(TypeVector)
107100
addr.vec = b.g.alloc(size)
108101
return addr
109102
}

0 commit comments

Comments
 (0)