Skip to content

Commit 09c37a3

Browse files
Simplify isLast: use remainingStreamingBytes == 0 instead of local variable
Co-authored-by: uNetworkingAB <110806833+uNetworkingAB@users.noreply.github.com> Agent-Logs-Url: https://github.com/uNetworking/uWebSockets/sessions/7ac360f2-a931-4011-946c-10163706a39d
1 parent 17406e7 commit 09c37a3

1 file changed

Lines changed: 3 additions & 6 deletions

File tree

src/HttpParser.h

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -598,9 +598,8 @@ struct HttpParser {
598598

599599
if (!CONSUME_MINIMALLY) {
600600
unsigned int emittable = (unsigned int) std::min<uint64_t>(remainingStreamingBytes, length);
601-
bool isLast = emittable == remainingStreamingBytes;
602601
remainingStreamingBytes -= emittable;
603-
dataHandler(user, std::string_view(data, emittable), isLast);
602+
dataHandler(user, std::string_view(data, emittable), remainingStreamingBytes == 0);
604603

605604
data += emittable;
606605
length -= emittable;
@@ -663,9 +662,8 @@ struct HttpParser {
663662
// this is exactly the same as below!
664663
// todo: refactor this
665664
if (remainingStreamingBytes >= length) {
666-
bool isLast = remainingStreamingBytes == length;
667665
remainingStreamingBytes -= length;
668-
void *returnedUser = dataHandler(user, std::string_view(data, length), isLast);
666+
void *returnedUser = dataHandler(user, std::string_view(data, length), remainingStreamingBytes == 0);
669667
return {0, returnedUser};
670668
} else {
671669
unsigned int toConsume = (unsigned int) remainingStreamingBytes;
@@ -728,9 +726,8 @@ struct HttpParser {
728726
} else {
729727
// this is exactly the same as above!
730728
if (remainingStreamingBytes >= (unsigned int) length) {
731-
bool isLast = remainingStreamingBytes == (unsigned int) length;
732729
remainingStreamingBytes -= length;
733-
void *returnedUser = dataHandler(user, std::string_view(data, length), isLast);
730+
void *returnedUser = dataHandler(user, std::string_view(data, length), remainingStreamingBytes == 0);
734731
return {0, returnedUser};
735732
} else {
736733
unsigned int toConsume = (unsigned int) remainingStreamingBytes;

0 commit comments

Comments
 (0)