优化代码

This commit is contained in:
GoEdgeLab
2021-12-19 11:32:26 +08:00
parent b2fd11f8f4
commit 3ab0f64b18
14 changed files with 154 additions and 66 deletions

View File

@@ -803,9 +803,9 @@ func (this *FileStorage) decodeFile(path string) (*Item, error) {
// URL
if urlSize > 0 {
data := utils.BytePool1024.Get()
data := utils.BytePool1k.Get()
result, ok, err := this.readN(fp, data, int(urlSize))
utils.BytePool1024.Put(data)
utils.BytePool1k.Put(data)
if err != nil {
return nil, err
}
@@ -942,7 +942,8 @@ func (this *FileStorage) hotLoop() {
size = len(result) / 10
}
var buf = make([]byte, 32*1024)
var buf = utils.BytePool16k.Get()
defer utils.BytePool16k.Put(buf)
for _, item := range result[:size] {
reader, err := this.openReader(item.Key, false, false)
if err != nil {