Skip to content

Commit

Permalink
perf: avoid calling into destroyMaybe
Browse files Browse the repository at this point in the history
  • Loading branch information
ronag committed May 3, 2020
1 parent 5bd60c2 commit ffcb3dc
Showing 1 changed file with 6 additions and 3 deletions.
9 changes: 6 additions & 3 deletions lib/client.js
Original file line number Diff line number Diff line change
Expand Up @@ -270,7 +270,9 @@ class Client extends EventEmitter {
headers: parseHeaders(headers),
body: this[kLastBody]
})
destroyMaybe(this)
if (this.closed) {
destroyMaybe(this)
}
return skipBody
}

Expand All @@ -284,7 +286,9 @@ class Client extends EventEmitter {
if (body !== null) {
body.push(null)
}
destroyMaybe(this)
if (this.closed) {
destroyMaybe(this)
}
}
}
this[kResetParser]()
Expand Down Expand Up @@ -428,7 +432,6 @@ module.exports = Client

function destroyMaybe (client) {
if (
client.closed &&
!client[kLastBody] &&
client[kQueue].length() === 0 &&
client[kInflight].length === 0
Expand Down

0 comments on commit ffcb3dc

Please sign in to comment.