1
0
mirror of https://github.com/v2fly/v2ray-core.git synced 2025-12-26 12:05:35 -05:00

reduce memory usage in log

This commit is contained in:
v2ray
2016-04-29 23:40:28 +02:00
parent dd8ce6f164
commit 5390e8efff
4 changed files with 29 additions and 10 deletions

View File

@@ -49,6 +49,11 @@ func (b *Buffer) Append(data []byte) *Buffer {
return b
}
func (b *Buffer) AppendString(s string) *Buffer {
b.Value = append(b.Value, s...)
return b
}
// Prepend prepends bytes in front of the buffer. Caller must ensure total bytes prepended is
// no more than 16 bytes.
func (b *Buffer) Prepend(data []byte) *Buffer {
@@ -131,6 +136,10 @@ func (b *Buffer) FillFrom(reader io.Reader) (int, error) {
return nBytes, err
}
func (b *Buffer) String() string {
return string(b.Value)
}
// NewSmallBuffer creates a Buffer with 1K bytes of arbitrary content.
func NewSmallBuffer() *Buffer {
return smallPool.Allocate()