fix: SplitBuffers函数导致修改原数组的内容的bug

This commit is contained in:
dexter
2022-03-13 23:24:03 +08:00
parent c40665125f
commit e31fb41b6e
2 changed files with 2 additions and 1 deletions

View File

@@ -97,6 +97,7 @@ func SizeOfBuffers[T ~[]byte](buf []T) (size int) {
// SplitBuffers 按照一定大小分割 Buffers
func SplitBuffers[T ~[]byte](buf []T, size int) (result [][]T) {
buf = append([]T(nil), buf...)
for total := SizeOfBuffers(buf); total > 0; {
if total <= size {
return append(result, buf)