mirror of
https://github.com/tw93/Mole.git
synced 2026-02-09 06:44:20 +00:00
refactor: simplify with slices.Clone
This commit is contained in:
@@ -7,6 +7,7 @@ import (
|
||||
"fmt"
|
||||
"os"
|
||||
"path/filepath"
|
||||
"slices"
|
||||
"sync"
|
||||
"time"
|
||||
|
||||
@@ -27,8 +28,8 @@ var (
|
||||
func snapshotFromModel(m model) historyEntry {
|
||||
return historyEntry{
|
||||
Path: m.path,
|
||||
Entries: cloneDirEntries(m.entries),
|
||||
LargeFiles: cloneFileEntries(m.largeFiles),
|
||||
Entries: slices.Clone(m.entries),
|
||||
LargeFiles: slices.Clone(m.largeFiles),
|
||||
TotalSize: m.totalSize,
|
||||
TotalFiles: m.totalFiles,
|
||||
Selected: m.selected,
|
||||
@@ -45,24 +46,6 @@ func cacheSnapshot(m model) historyEntry {
|
||||
return entry
|
||||
}
|
||||
|
||||
func cloneDirEntries(entries []dirEntry) []dirEntry {
|
||||
if len(entries) == 0 {
|
||||
return nil
|
||||
}
|
||||
copied := make([]dirEntry, len(entries))
|
||||
copy(copied, entries) //nolint:all
|
||||
return copied
|
||||
}
|
||||
|
||||
func cloneFileEntries(files []fileEntry) []fileEntry {
|
||||
if len(files) == 0 {
|
||||
return nil
|
||||
}
|
||||
copied := make([]fileEntry, len(files))
|
||||
copy(copied, files) //nolint:all
|
||||
return copied
|
||||
}
|
||||
|
||||
func ensureOverviewSnapshotCacheLocked() error {
|
||||
if overviewSnapshotLoaded {
|
||||
return nil
|
||||
|
||||
Reference in New Issue
Block a user