mirror of
https://github.com/octoleo/syncthing.git
synced 2025-01-24 07:28:27 +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 {
|
if debug {
|
||||||
dlog.Printf("Need(%d)", id)
|
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()
|
m.Lock()
|
||||||
rkID := m.remoteKey[id]
|
rkID := m.remoteKey[id]
|
||||||
for name, gk := range m.globalKey {
|
for name, gk := range m.globalKey {
|
||||||
@ -162,7 +162,7 @@ func (m *Set) Have(id uint) []scanner.File {
|
|||||||
if debug {
|
if debug {
|
||||||
dlog.Printf("Have(%d)", id)
|
dlog.Printf("Have(%d)", id)
|
||||||
}
|
}
|
||||||
var fs []scanner.File
|
var fs = make([]scanner.File, 0, len(m.remoteKey[id]))
|
||||||
m.Lock()
|
m.Lock()
|
||||||
for _, rk := range m.remoteKey[id] {
|
for _, rk := range m.remoteKey[id] {
|
||||||
fs = append(fs, m.files[rk].File)
|
fs = append(fs, m.files[rk].File)
|
||||||
@ -175,7 +175,7 @@ func (m *Set) Global() []scanner.File {
|
|||||||
if debug {
|
if debug {
|
||||||
dlog.Printf("Global()")
|
dlog.Printf("Global()")
|
||||||
}
|
}
|
||||||
var fs []scanner.File
|
var fs = make([]scanner.File, 0, len(m.globalKey))
|
||||||
m.Lock()
|
m.Lock()
|
||||||
for _, rk := range m.globalKey {
|
for _, rk := range m.globalKey {
|
||||||
fs = append(fs, m.files[rk].File)
|
fs = append(fs, m.files[rk].File)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user