mirror of
https://github.com/octoleo/syncthing.git
synced 2024-11-14 09:14:10 +00:00
Preallocate slices in fileset
This commit is contained in:
parent
94f5d5b59e
commit
e974c8f33e
@ -143,7 +143,7 @@ func (m *Set) Need(id uint) []scanner.File {
|
||||
if debug {
|
||||
dlog.Printf("Need(%d)", id)
|
||||
}
|
||||
var fs []scanner.File
|
||||
var fs = make([]scanner.File, 0, len(m.globalKey)/2) // Just a guess, but avoids too many reallocations
|
||||
m.Lock()
|
||||
rkID := m.remoteKey[id]
|
||||
for name, gk := range m.globalKey {
|
||||
@ -162,7 +162,7 @@ func (m *Set) Have(id uint) []scanner.File {
|
||||
if debug {
|
||||
dlog.Printf("Have(%d)", id)
|
||||
}
|
||||
var fs []scanner.File
|
||||
var fs = make([]scanner.File, 0, len(m.remoteKey[id]))
|
||||
m.Lock()
|
||||
for _, rk := range m.remoteKey[id] {
|
||||
fs = append(fs, m.files[rk].File)
|
||||
@ -175,7 +175,7 @@ func (m *Set) Global() []scanner.File {
|
||||
if debug {
|
||||
dlog.Printf("Global()")
|
||||
}
|
||||
var fs []scanner.File
|
||||
var fs = make([]scanner.File, 0, len(m.globalKey))
|
||||
m.Lock()
|
||||
for _, rk := range m.globalKey {
|
||||
fs = append(fs, m.files[rk].File)
|
||||
|
Loading…
Reference in New Issue
Block a user