From 77e4b1376e55e3437d5d18f3fe4c7003882121e8 Mon Sep 17 00:00:00 2001 From: chrislu Date: Sun, 21 Aug 2022 11:35:54 -0700 Subject: [PATCH] refactoring --- weed/filer/reader_at.go | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/weed/filer/reader_at.go b/weed/filer/reader_at.go index e18324068..6f9734b7e 100644 --- a/weed/filer/reader_at.go +++ b/weed/filer/reader_at.go @@ -129,7 +129,7 @@ func (c *ChunkReadAt) doReadAt(p []byte, offset int64) (n int, err error) { if startOffset < chunk.LogicOffset { gap := chunk.LogicOffset - startOffset glog.V(4).Infof("zero [%d,%d)", startOffset, chunk.LogicOffset) - c.zero(p, startOffset-offset, gap) + zero(p, startOffset-offset, gap) n += int(min(gap, remaining)) startOffset, remaining = chunk.LogicOffset, remaining-gap if remaining <= 0 { @@ -166,7 +166,7 @@ func (c *ChunkReadAt) doReadAt(p []byte, offset int64) (n int, err error) { startOffset = max(startOffset-offset, startOffset-remaining-offset) } glog.V(4).Infof("zero2 [%d,%d) of file size %d bytes", startOffset, startOffset+delta, c.fileSize) - c.zero(p, startOffset, delta) + zero(p, startOffset, delta) n += int(delta) } @@ -206,7 +206,7 @@ func (c *ChunkReadAt) readChunkSliceAt(buffer []byte, chunkView *ChunkView, next return } -func (c *ChunkReadAt) zero(buffer []byte, start, length int64) { +func zero(buffer []byte, start, length int64) { end := min(start+length, int64(len(buffer))) // zero the bytes