Skip to content

Commit

Permalink
more short-circuits
Browse files Browse the repository at this point in the history
  • Loading branch information
puellanivis committed Feb 6, 2024
1 parent ba3d6ab commit 72aa403
Showing 1 changed file with 6 additions and 0 deletions.
6 changes: 6 additions & 0 deletions packet.go
Original file line number Diff line number Diff line change
Expand Up @@ -737,6 +737,8 @@ func (p *sshFxpOpenPacket) marshalPacket() ([]byte, []byte, error) {
b = marshalUint32(b, p.Flags)

switch attrs := p.Attrs.(type) {
case []byte:
return b, attrs, nil // may as well short-ciruit this case.
case os.FileInfo:
_, fs := fileStatFromInfo(attrs) // we throw away the flags, and override with those in packet.
return b, marshalFileStat(nil, p.Flags, fs), nil
Expand Down Expand Up @@ -1008,6 +1010,8 @@ func (p *sshFxpSetstatPacket) marshalPacket() ([]byte, []byte, error) {
b = marshalUint32(b, p.Flags)

switch attrs := p.Attrs.(type) {
case []byte:
return b, attrs, nil // may as well short-ciruit this case.
case os.FileInfo:
_, fs := fileStatFromInfo(attrs) // we throw away the flags, and override with those in packet.
return b, marshalFileStat(nil, p.Flags, fs), nil
Expand Down Expand Up @@ -1035,6 +1039,8 @@ func (p *sshFxpFsetstatPacket) marshalPacket() ([]byte, []byte, error) {
b = marshalUint32(b, p.Flags)

switch attrs := p.Attrs.(type) {
case []byte:
return b, attrs, nil // may as well short-ciruit this case.
case os.FileInfo:
_, fs := fileStatFromInfo(attrs) // we throw away the flags, and override with those in packet.
return b, marshalFileStat(nil, p.Flags, fs), nil
Expand Down

0 comments on commit 72aa403

Please sign in to comment.