reduce pointer usage

This commit is contained in:
Chris Lu 2018-12-31 15:10:14 -08:00
parent 1478d7ea21
commit 832ac8129a
2 changed files with 8 additions and 8 deletions

View file

@ -81,7 +81,7 @@ func ViewFromChunks(chunks []*filer_pb.FileChunk, offset int64, size int) (views
}
func ViewFromVisibleIntervals(visibles []*VisibleInterval, offset int64, size int) (views []*ChunkView) {
func ViewFromVisibleIntervals(visibles []VisibleInterval, offset int64, size int) (views []*ChunkView) {
stop := offset + int64(size)
@ -103,7 +103,7 @@ func ViewFromVisibleIntervals(visibles []*VisibleInterval, offset int64, size in
}
func logPrintf(name string, visibles []*VisibleInterval) {
func logPrintf(name string, visibles []VisibleInterval) {
/*
log.Printf("%s len %d", name, len(visibles))
for _, v := range visibles {
@ -118,7 +118,7 @@ var bufPool = sync.Pool{
},
}
func mergeIntoVisibles(visibles, newVisibles []*VisibleInterval, chunk *filer_pb.FileChunk) []*VisibleInterval {
func mergeIntoVisibles(visibles, newVisibles []VisibleInterval, chunk *filer_pb.FileChunk) []VisibleInterval {
newV := newVisibleInterval(
chunk.Offset,
@ -179,13 +179,13 @@ func mergeIntoVisibles(visibles, newVisibles []*VisibleInterval, chunk *filer_pb
return newVisibles
}
func NonOverlappingVisibleIntervals(chunks []*filer_pb.FileChunk) (visibles []*VisibleInterval) {
func NonOverlappingVisibleIntervals(chunks []*filer_pb.FileChunk) (visibles []VisibleInterval) {
sort.Slice(chunks, func(i, j int) bool {
return chunks[i].Mtime < chunks[j].Mtime
})
var newVislbles []*VisibleInterval
var newVislbles []VisibleInterval
for _, chunk := range chunks {
newVislbles = mergeIntoVisibles(visibles, newVislbles, chunk)
t := visibles[:0]
@ -210,8 +210,8 @@ type VisibleInterval struct {
isFullChunk bool
}
func newVisibleInterval(start, stop int64, fileId string, modifiedTime int64, isFullChunk bool) *VisibleInterval {
return &VisibleInterval{
func newVisibleInterval(start, stop int64, fileId string, modifiedTime int64, isFullChunk bool) VisibleInterval {
return VisibleInterval{
start: start,
stop: stop,
fileId: fileId,

View file

@ -24,7 +24,7 @@ type File struct {
dir *Dir
wfs *WFS
entry *filer_pb.Entry
entryViewCache []*filer2.VisibleInterval
entryViewCache []filer2.VisibleInterval
isOpen bool
}