diff --git a/go.mod b/go.mod index 3b0af5a..7a96c97 100644 --- a/go.mod +++ b/go.mod @@ -1,7 +1,7 @@ module github.com/yggdrasil-network/yggdrasil-go require ( - github.com/Arceliar/phony v0.0.0-20190831050304-94a6d3da9ba4 + github.com/Arceliar/phony v0.0.0-20190831212216-7018ff05d824 github.com/gologme/log v0.0.0-20181207131047-4e5d8ccb38e8 github.com/hashicorp/go-syslog v1.0.0 github.com/hjson/hjson-go v0.0.0-20181010104306-a25ecf6bd222 diff --git a/go.sum b/go.sum index df7ff63..b0b891e 100644 --- a/go.sum +++ b/go.sum @@ -1,5 +1,5 @@ -github.com/Arceliar/phony v0.0.0-20190831050304-94a6d3da9ba4 h1:OePImnPRBqS6JiHuVVq4Rfvt2yyhqMpWCB63PrwGrJE= -github.com/Arceliar/phony v0.0.0-20190831050304-94a6d3da9ba4/go.mod h1:6Lkn+/zJilRMsKmbmG1RPoamiArC6HS73xbwRyp3UyI= +github.com/Arceliar/phony v0.0.0-20190831212216-7018ff05d824 h1:JY7qh6yR87H8xgPUTYrrqa5cajb7zynKsbAdjhsVkyU= +github.com/Arceliar/phony v0.0.0-20190831212216-7018ff05d824/go.mod h1:6Lkn+/zJilRMsKmbmG1RPoamiArC6HS73xbwRyp3UyI= github.com/gologme/log v0.0.0-20181207131047-4e5d8ccb38e8 h1:WD8iJ37bRNwvETMfVTusVSAi0WdXTpfNVGY2aHycNKY= github.com/gologme/log v0.0.0-20181207131047-4e5d8ccb38e8/go.mod h1:gq31gQ8wEHkR+WekdWsqDuf8pXTUZA9BnnzTuPz1Y9U= github.com/hashicorp/go-syslog v1.0.0 h1:KaodqZuhUoZereWVIYmpUgZysurB1kBLX2j0MwMrUAE= diff --git a/src/util/bytes_mobile.go b/src/util/bytes_mobile.go new file mode 100644 index 0000000..ceab763 --- /dev/null +++ b/src/util/bytes_mobile.go @@ -0,0 +1,13 @@ +//+build mobile + +package util + +// On mobile, just return a nil slice. +func GetBytes() []byte { + return nil +} + +// On mobile, don't do anything. +func PutBytes(bs []byte) { + return +} diff --git a/src/util/bytes_other.go b/src/util/bytes_other.go new file mode 100644 index 0000000..41b8bec --- /dev/null +++ b/src/util/bytes_other.go @@ -0,0 +1,18 @@ +//+build !mobile + +package util + +import "sync" + +// This is used to buffer recently used slices of bytes, to prevent allocations in the hot loops. +var byteStore = sync.Pool{New: func() interface{} { return []byte(nil) }} + +// Gets an empty slice from the byte store. +func GetBytes() []byte { + return byteStore.Get().([]byte)[:0] +} + +// Puts a slice in the store. +func PutBytes(bs []byte) { + byteStore.Put(bs) +} diff --git a/src/util/util.go b/src/util/util.go index a588a35..9725012 100644 --- a/src/util/util.go +++ b/src/util/util.go @@ -6,7 +6,6 @@ import ( "runtime" "strconv" "strings" - "sync" "time" ) @@ -25,19 +24,6 @@ func UnlockThread() { runtime.UnlockOSThread() } -// This is used to buffer recently used slices of bytes, to prevent allocations in the hot loops. -var byteStore = sync.Pool{New: func() interface{} { return []byte(nil) }} - -// Gets an empty slice from the byte store. -func GetBytes() []byte { - return byteStore.Get().([]byte)[:0] -} - -// Puts a slice in the store. -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 {