refactor: optimize prepQuotedPrintable() with hash lookup and int-length tracking#10344
Merged
paulbalandan merged 2 commits intoJun 30, 2026
Merged
Conversation
4f43143 to
2af2294
Compare
paulbalandan
approved these changes
Jun 29, 2026
michalsn
requested changes
Jun 29, 2026
michalsn
left a comment
Member
There was a problem hiding this comment.
Please restore the comments that remain relevant after the refactor, especially those explaining the {unwrap} removal, the custom-LF compatibility path, encoding of =, and the line-wrapping rules. These capture non-obvious behavior and will make our lives easier in the future.
… tracking, and sprintf encoding
ce158a2 to
44ce027
Compare
prepQuotedPrintable() with hash lookup and int-length tracking
Member
|
Thank you, @gr8man |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
Optimize
prepQuotedPrintable()insystem/Email/Email.phpby replacing three expensive patterns in the hot loop:in_array($ascii, $asciiSafeChars)→isset($asciiSafeChars[$ascii])usingarray_fill_keys()static::strlen($temp) + static::strlen($char)→ integer$tempLenvariable, incremented/decremented$escape . strtoupper(sprintf('%02s', dechex($ascii)))+static::strlen($char)→sprintf('=%02X', $ascii)with preset$charLen = 3Added unit tests covering safe chars, unsafe chars, trailing space/tab,
=3D, soft line breaks at 76 chars,{unwrap}removal, null-byte stripping, both CRLF paths, and mixed content.