mirror of
https://github.com/Monibuca/engine.git
synced 2025-10-29 19:11:56 +08:00
优化amf读取
This commit is contained in:
27
util/pool.go
27
util/pool.go
@@ -69,6 +69,29 @@ func (r *BLLReader) ReadN(n int) (result net.Buffers) {
|
||||
return
|
||||
}
|
||||
|
||||
type BLLsReader struct {
|
||||
*ListItem[*BLL]
|
||||
BLLReader
|
||||
}
|
||||
|
||||
func (r *BLLsReader) CanRead() bool {
|
||||
return r.ListItem != nil && !r.IsRoot()
|
||||
}
|
||||
|
||||
func (r *BLLsReader) ReadByte() (b byte, err error) {
|
||||
if r.BLLReader.CanRead() {
|
||||
b, err = r.BLLReader.ReadByte()
|
||||
if err == nil {
|
||||
return
|
||||
}
|
||||
}
|
||||
r.ListItem = r.Next
|
||||
if !r.CanRead() {
|
||||
return 0, io.EOF
|
||||
}
|
||||
r.BLLReader = *r.Value.NewReader()
|
||||
return r.BLLReader.ReadByte()
|
||||
}
|
||||
type BLLs struct {
|
||||
List[*BLL]
|
||||
ByteLength int
|
||||
@@ -121,6 +144,10 @@ func (list *BLLs) Recycle() {
|
||||
list.ByteLength = 0
|
||||
}
|
||||
|
||||
func (list *BLLs) NewReader() *BLLsReader {
|
||||
return &BLLsReader{list.Next, *list.Next.Value.NewReader()}
|
||||
}
|
||||
|
||||
// ByteLinkList
|
||||
type BLL struct {
|
||||
List[BLI]
|
||||
|
||||
Reference in New Issue
Block a user