Cleaned up allocations in PeelOnion

This commit is contained in:
David Vennik
2022-12-24 17:07:04 +00:00
parent 676a583b9d
commit b0b303fb6f
3 changed files with 20 additions and 20 deletions

View File

@@ -35,35 +35,35 @@ func EncodeOnion(on types.Onion) (b slice.Bytes) {
func PeelOnion(b slice.Bytes, c *slice.Cursor) (on types.Onion, e error) {
switch b[*c:c.Inc(magicbytes.Len)].String() {
case cipher.MagicString:
var o cipher.OnionSkin
o := &cipher.OnionSkin{}
if e = o.Decode(b, c); check(e) {
return
}
on = &o
on = o
case confirmation.MagicString:
var o confirmation.OnionSkin
o := &confirmation.OnionSkin{}
if e = o.Decode(b, c); check(e) {
return
}
on = &o
on = o
case delay.MagicString:
var o delay.OnionSkin
o := &delay.OnionSkin{}
if e = o.Decode(b, c); check(e) {
return
}
on = &o
on = o
case exit.MagicString:
var o exit.OnionSkin
o := &exit.OnionSkin{}
if e = o.Decode(b, c); check(e) {
return
}
on = &o
on = o
case forward.MagicString:
var o forward.OnionSkin
o := &forward.OnionSkin{}
if e = o.Decode(b, c); check(e) {
return
}
on = &o
on = o
case message.MagicString:
var o message.OnionSkin
if e = o.Decode(b, c); check(e) {
@@ -77,23 +77,23 @@ func PeelOnion(b slice.Bytes, c *slice.Cursor) (on types.Onion, e error) {
}
on = o
case reply.MagicString:
var o reply.OnionSkin
o := &reply.OnionSkin{}
if e = o.Decode(b, c); check(e) {
return
}
on = &o
on = o
case response.MagicString:
o := response.NewResponse()
o := response.New()
if e = o.Decode(b, c); check(e) {
return
}
on = o
case session.MagicString:
var o session.OnionSkin
o := &session.OnionSkin{}
if e = o.Decode(b, c); check(e) {
return
}
on = &o
on = o
case token.MagicString:
o := token.NewOnionSkin()
if e = o.Decode(b, c); check(e) {

View File

@@ -20,7 +20,7 @@ var (
// OnionSkin messages are what are carried back via Reply messages from an Exit.
type OnionSkin slice.Bytes
func NewResponse() *OnionSkin {
func New() *OnionSkin {
o := OnionSkin{}
return &o
}

View File

@@ -10,11 +10,11 @@ var (
// GitRef is the gitref, as in refs/heads/branchname.
GitRef = "refs/heads/main"
// ParentGitCommit is the commit hash of the parent HEAD.
ParentGitCommit = "749ad5f24fff3a4e79d8dd676fc0d971325e2f39"
ParentGitCommit = "ff65fa2f04bdd776dff598f63343b2e1dcc07679"
// BuildTime stores the time when the current binary was built.
BuildTime = "2022-12-24T16:58:35Z"
BuildTime = "2022-12-24T17:07:04Z"
// SemVer lists the (latest) git tag on the build.
SemVer = "v0.0.235"
SemVer = "v0.0.236"
// PathBase is the path base returned from runtime caller.
PathBase = "/home/loki/src/github.com/Indra-Labs/indra/"
// Major is the major number from the tag.
@@ -22,7 +22,7 @@ var (
// Minor is the minor number from the tag.
Minor = 0
// Patch is the patch version number from the tag.
Patch = 235
Patch = 236
)
// Version returns a pretty printed version information string.