From 0fddede9f731d1bffe23c88e412f284cca6b4c1c Mon Sep 17 00:00:00 2001 From: Sergei Lukianov Date: Tue, 10 Sep 2024 09:13:30 -0700 Subject: [PATCH] Remove unnecessary clusters key sorting in fat32 --- filesystem/fat32/fat32.go | 6 ------ 1 file changed, 6 deletions(-) diff --git a/filesystem/fat32/fat32.go b/filesystem/fat32/fat32.go index 6e5a7463..7c6cfb1f 100644 --- a/filesystem/fat32/fat32.go +++ b/filesystem/fat32/fat32.go @@ -5,7 +5,6 @@ import ( "fmt" "os" "path" - "sort" "strings" "time" @@ -933,7 +932,6 @@ func (fs *FileSystem) allocateSpace(size uint64, previous uint32) ([]uint32, err // 1- calculate how many clusters needed // 2- see how many clusters already are allocated // 3- if needed, allocate new clusters and extend the chain in the FAT table - keys := make([]uint32, 0, 20) allocated := make([]uint32, 0, 20) // what is the total count of clusters needed? @@ -965,10 +963,6 @@ func (fs *FileSystem) allocateSpace(size uint64, previous uint32) ([]uint32, err // get a list of allocated clusters, so we can know which ones are unallocated and therefore allocatable allClusters := fs.table.clusters maxCluster := fs.table.maxCluster - for k := range allClusters { - keys = append(keys, k) - } - sort.Slice(keys, func(i, j int) bool { return keys[i] < keys[j] }) if extraClusterCount > 0 { for i := uint32(2); i < maxCluster && len(allocated) < extraClusterCount; i++ {