mirror of
https://github.com/SagerNet/sing.git
synced 2025-04-04 20:37:40 +03:00
Add buffer.LenMulti
This commit is contained in:
parent
8dcfcc6959
commit
c4e9bf11fa
2 changed files with 23 additions and 12 deletions
|
@ -321,18 +321,6 @@ func (b *Buffer) Release() {
|
|||
*b = Buffer{closed: true}
|
||||
}
|
||||
|
||||
func ReleaseMulti(buffers []*Buffer) {
|
||||
for _, buffer := range buffers {
|
||||
buffer.Release()
|
||||
}
|
||||
}
|
||||
|
||||
func ToSliceMulti(buffers []*Buffer) [][]byte {
|
||||
return common.Map(buffers, func(it *Buffer) []byte {
|
||||
return it.Bytes()
|
||||
})
|
||||
}
|
||||
|
||||
func (b *Buffer) Cut(start int, end int) *Buffer {
|
||||
b.start += start
|
||||
b.end = len(b.data) - end
|
||||
|
|
23
common/buf/multi.go
Normal file
23
common/buf/multi.go
Normal file
|
@ -0,0 +1,23 @@
|
|||
package buf
|
||||
|
||||
import "github.com/sagernet/sing/common"
|
||||
|
||||
func LenMulti(buffers []*Buffer) int {
|
||||
var n int
|
||||
for _, buffer := range buffers {
|
||||
n += buffer.Len()
|
||||
}
|
||||
return n
|
||||
}
|
||||
|
||||
func ToSliceMulti(buffers []*Buffer) [][]byte {
|
||||
return common.Map(buffers, func(it *Buffer) []byte {
|
||||
return it.Bytes()
|
||||
})
|
||||
}
|
||||
|
||||
func ReleaseMulti(buffers []*Buffer) {
|
||||
for _, buffer := range buffers {
|
||||
buffer.Release()
|
||||
}
|
||||
}
|
Loading…
Add table
Add a link
Reference in a new issue