Skip to content

♻️ Refactor Net::IMAP#get_response (internal) #422

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
Mar 25, 2025

Conversation

nevans
Copy link
Collaborator

@nevans nevans commented Mar 25, 2025

IMO, this refactoring makes Net::IMAP#get_response much easier to understand.
Which will be useful, because I'm about to complicate it. 😉

Details in each commit.

nevans added 6 commits March 25, 2025 14: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 0edda3c into master Mar 25, 2025
37 checks passed
@nevans nevans deleted the refactor-get_response branch March 25, 2025 18:38
nevans added a commit that referenced this pull request Apr 18, 2025
…response

♻️ Refactor `get_response` (backports #422 to 0.4)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant