1
0
mirror of https://github.com/fumiama/terasu.git synced 2026-06-24 23:00:27 +08:00

release: v1.0.0

This commit is contained in:
源文雨
2025-10-23 01:19:16 +08:00
parent 541b84ca4a
commit 352a675ea1
21 changed files with 354 additions and 2529 deletions

28
builder.go Normal file
View File

@@ -0,0 +1,28 @@
package terasu
import (
"io"
"net"
)
type builder net.Buffers
func newbuilder() builder {
return builder{}
}
// move is write without copy
func (bd *builder) move(b []byte) {
*bd = append(*bd, b)
}
func (bd *builder) send(conn *net.TCPConn, rs ...io.Reader) (int64, error) {
if len(rs) == 0 {
return conn.ReadFrom((*net.Buffers)(bd))
}
return conn.ReadFrom(io.MultiReader(append([]io.Reader{(*net.Buffers)(bd)}, rs...)...))
}
func (bd *builder) reset() {
*bd = (*bd)[:0]
}