INNER CODE UNIT · Go
CalculateNumChunks
benbusby/yeetfile · shared/utils.go:102
func CalculateNumChunks(fileSize int64) int {
return int(math.Ceil(float64(fileSize) / float64(constants.ChunkSize)))
}
func RemoveOverlap[T comparable](source []T, remove []T) []T {
// Create a map to store the elements to be removed for quick lookup
toRemove := make(map[T]struct{}, len(remove))
for _, item := range remove {
toRemove[item] = struct{}{}
}
// Create a new slice to store the filtered elements
var filtered []T
for _, item := range source {
if _, found := toRemove[item]; !found {
filtered = append(filtered, item)
}
}