Skip to content

Commit

Permalink
Optimize out strlen call
Browse files Browse the repository at this point in the history
As the buffer max size is known, can check last byte with isset

Signed-off-by: Elan Ruusamäe <[email protected]>
  • Loading branch information
glensc committed Feb 27, 2021
1 parent deb8f00 commit dd7b423
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/Protocol/Smtp.php
Original file line number Diff line number Diff line change
Expand Up @@ -331,7 +331,7 @@ public function data($data)
$line .= $buffer;

// partial read, continue loop to read again to complete the line
if (strlen($buffer) === $chunkSize - 1 && $buffer[$chunkSize - 2] !== "\n") {
if (isset($buffer[$chunkSize - 2]) && $buffer[$chunkSize - 2] !== "\n") {
continue;
}

Expand Down

0 comments on commit dd7b423

Please sign in to comment.