使用空struct{}代替bool节约内存

This commit is contained in:
GoEdgeLab
2021-12-09 12:07:46 +08:00
parent 6be26c0ffb
commit 82709e274c
15 changed files with 126 additions and 63 deletions

View File

@@ -2,6 +2,7 @@ package nodes
import (
teaconst "github.com/TeaOSLab/EdgeNode/internal/const"
"github.com/TeaOSLab/EdgeNode/internal/zero"
"github.com/iwind/TeaGo/assert"
"runtime"
"sync"
@@ -72,7 +73,7 @@ func TestHTTPRequest_httpRequestNextId(t *testing.T) {
}
func TestHTTPRequest_httpRequestNextId_Concurrent(t *testing.T) {
var m = map[string]bool{}
var m = map[string]zero.Zero{}
var locker = sync.Mutex{}
var count = 4000
@@ -94,7 +95,7 @@ func TestHTTPRequest_httpRequestNextId_Concurrent(t *testing.T) {
countDuplicated++
}
m[requestId] = true
m[requestId] = zero.New()
locker.Unlock()
}()
}