Skip to content

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

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 6 commits into from
Apr 18, 2025

Conversation

nevans
Copy link
Collaborator

@nevans nevans commented Apr 18, 2025

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
30 checks passed
@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