Commit 056465bb authored by cznic's avatar cznic
Browse files

Export {newMemDB,newDictionary}.

parent 5fc7735d
......@@ -2,32 +2,40 @@
# Use of this source code is governed by a BSD-style
# license that can be found in the LICENSE file.
.PHONY: all clean cover cpu editor internalError later mem nuke todo
.PHONY: all clean cover cpu editor internalError later mem nuke todo edit
grep=--include=*.go --include=*.l --include=*.y
grep=--include=*.go --include=*.l --include=*.y --include=*.yy
ngrep='TODOOK\|parser\.go\|scanner\.go\|.*_string\.go'
all: editor
go vet
golint
go vet 2>&1 | grep -v $(ngrep) || true
golint 2>&1 | grep -v $(ngrep) || true
make todo
unused . || true
misspell *.go
gosimple || true
codesweep || true
maligned || true
unconvert -apply
clean:
go clean
rm -f *~ cpu.test mem.test
rm -f *~ *.test *.out
cover:
t=$(shell tempfile) ; go test -coverprofile $$t && go tool cover -html $$t && unlink $$t
cpu:
go test -c -o cpu.test
./cpu.test -noerr -test.cpuprofile cpu.out
go tool pprof --lines cpu.test cpu.out
cpu: clean
go test -run @ -bench . -cpuprofile cpu.out
go tool pprof -lines *.test cpu.out
edit:
@ 1>/dev/null 2>/dev/null gvim -p Makefile *.go
editor:
gofmt -l -s -w *.go
go test -i
go test
go test 2>&1 | tee log
go install
internalError:
......@@ -37,16 +45,15 @@ later:
@grep -n $(grep) LATER * || true
@grep -n $(grep) MAYBE * || true
mem:
go test -c -o mem.test
./mem.test -test.bench . -test.memprofile mem.out
go tool pprof --lines --web --alloc_space mem.test mem.out
mem: clean
go test -run @ -bench . -memprofile mem.out -memprofilerate 1 -timeout 24h
go tool pprof -lines -web -alloc_space *.test mem.out
nuke: clean
go clean -i
todo:
@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * || true
@grep -nr $(grep) TODO * || true
@grep -nr $(grep) BUG * || true
@grep -nr $(grep) [^[:alpha:]]println * || true
@grep -nr $(grep) ^[[:space:]]*_[[:space:]]*=[[:space:]][[:alpha:]][[:alnum:]]* * | grep -v $(ngrep) || true
@grep -nr $(grep) TODO * | grep -v $(ngrep) || true
@grep -nr $(grep) BUG * | grep -v $(ngrep) || true
@grep -nr $(grep) [^[:alpha:]]println * | grep -v $(ngrep) || true
......@@ -61,7 +61,7 @@ func newRng() *mathutil.FC32 {
func TestDBBytes(t *testing.T) {
const n = 29e4
rng := newRng()
db := newMemDB()
db := NewMemDB()
exp := map[int][]byte{}
var buf []byte
for i := 0; i < n; i++ {
......@@ -124,7 +124,7 @@ func TestDBBytes(t *testing.T) {
func TestDict(t *testing.T) {
const n = 15e4
dict := newDictionary()
dict := NewDictionary()
rng := newRng()
m := map[string]int{}
......
......@@ -26,7 +26,8 @@ type MemDB struct {
pages [][]byte
}
func newMemDB() *MemDB {
// NewMemDB returns a newly create *MemDB.
func NewMemDB() *MemDB {
d := &MemDB{}
for i := 0; i < 256; i++ {
d.b256[i] = byte(i)
......
......@@ -90,7 +90,8 @@ type Dictionary struct {
r interface{}
}
func newDictionary() *Dictionary {
// NewDictionary returns a newly created *Dictionary.
func NewDictionary() *Dictionary {
return &Dictionary{}
}
......
......@@ -23,11 +23,11 @@ import (
var (
// DB keeps parser/compiler data shared between stages. See also *MemDB
// methods.
DB = newMemDB()
DB = NewMemDB()
// Dict collects unique []byte values using the global DB variable.
// See also *Dictionary methods.
Dict = newDictionary()
Dict = NewDictionary()
// FileSet represents a set of source files.
FileSet = token.NewFileSet()
......
Supports Markdown
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment