mirror of
https://github.com/yggdrasil-network/yggdrasil-go.git
synced 2025-04-28 14:15:06 +03:00
WARNING: CRYPTO DISABLED while speeding up stream writeMsg
This commit is contained in:
parent
1e6a6d2160
commit
f52955ee0f
5 changed files with 28 additions and 13 deletions
|
@ -34,6 +34,15 @@ func PutBytes(bs []byte) {
|
|||
byteStore.Put(bs)
|
||||
}
|
||||
|
||||
// Gets a slice of the appropriate length, reusing existing slice capacity when possible
|
||||
func ResizeBytes(bs []byte, length int) []byte {
|
||||
if cap(bs) >= length {
|
||||
return bs[:length]
|
||||
} else {
|
||||
return make([]byte, length)
|
||||
}
|
||||
}
|
||||
|
||||
// This is a workaround to go's broken timer implementation
|
||||
func TimerStop(t *time.Timer) bool {
|
||||
stopped := t.Stop()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue