Skip to content

Commit

Permalink
Clean up unneccessary nested logic
Browse files Browse the repository at this point in the history
Cleans up a few unneccessary else blocks and nested if statements.

Signed-off-by: Daniel Mangum <georgedanielmangum@gmail.com>
  • Loading branch information
hasheddan committed Jul 11, 2023
1 parent 7307f62 commit b033847
Showing 1 changed file with 11 additions and 13 deletions.
24 changes: 11 additions & 13 deletions conn.go
Original file line number Diff line number Diff line change
Expand Up @@ -605,18 +605,17 @@ func (c *Conn) readAndBuffer(ctx context.Context) error {
}
}
}
if hs {
hasHandshake = true
}

var e *alertError
if errors.As(err, &e) {
if e.IsFatalOrCloseNotify() {
return e
}
} else if err != nil {
if errors.As(err, &e) && e.IsFatalOrCloseNotify() {
return e
}
if err != nil {
return err
}
if hs {
hasHandshake = true
}
}
if hasHandshake {
done := make(chan struct{})
Expand Down Expand Up @@ -645,11 +644,10 @@ func (c *Conn) handleQueuedPackets(ctx context.Context) error {
}
}
var e *alertError
if errors.As(err, &e) {
if e.IsFatalOrCloseNotify() {
return e
}
} else if err != nil {
if errors.As(err, &e) && e.IsFatalOrCloseNotify() {
return e
}
if err != nil {
return err
}
}
Expand Down

0 comments on commit b033847

Please sign in to comment.