Skip to content

♻️ Refactor get_response (backports #422 to 0.4)#431

Merged
nevans merged 6 commits into
v0.4-stablefrom
backport/v0.4-GH422-refactor-get_response
Apr 18, 2025
Merged

♻️ Refactor get_response (backports #422 to 0.4)#431
nevans merged 6 commits into
v0.4-stablefrom
backport/v0.4-GH422-refactor-get_response

Conversation

@nevans

@nevans nevans commented Apr 18, 2025

Copy link
Copy Markdown
Collaborator

Backports #422 to 0.4-stable

nevans added 6 commits April 17, 2025 21:19
This also allows us to check against the concatenated buffer, rather
than the smaller line buffer.  That distinction doesn't really matter
now, since we always read an entire line at once.  But it will matter if
we read partial lines.
IMO, this refactoring makes `get_response` much easier to understand.
Which will be useful, because I'm about to complicate it.  😉
We know exactly how much memory we're going to need, so we can allocate
this up-front, and save a few malloc/memcpy calls on larger literals.
This feels a lot more self-documenting than returning nil then breaking
when nil is returned.  Also, it lets me refactor the return values for
the get_response_line/get_response_literal methods, or throw from even
deeper in the stack.
@nevans nevans merged commit 4b30b02 into v0.4-stable Apr 18, 2025
@nevans nevans deleted the backport/v0.4-GH422-refactor-get_response branch April 18, 2025 02:38
@nevans nevans added the backport This issue or PR is for a stable release branch label Apr 22, 2025
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

backport This issue or PR is for a stable release branch

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant