Skip to content

refactor: optimize prepQuotedPrintable() with hash lookup and int-length tracking#10344

Open
gr8man wants to merge 2 commits into
codeigniter4:developfrom
gr8man:refactor/email-prep-quoted-printable
Open

refactor: optimize prepQuotedPrintable() with hash lookup and int-length tracking#10344
gr8man wants to merge 2 commits into
codeigniter4:developfrom
gr8man:refactor/email-prep-quoted-printable

Conversation

@gr8man

@gr8man gr8man commented Jun 28, 2026

Copy link
Copy Markdown
Contributor

Description

Optimize prepQuotedPrintable() in system/Email/Email.php by replacing three expensive patterns in the hot loop:

  • in_array($ascii, $asciiSafeChars)isset($asciiSafeChars[$ascii]) using array_fill_keys()
  • static::strlen($temp) + static::strlen($char) → integer $tempLen variable, incremented/decremented
  • $escape . strtoupper(sprintf('%02s', dechex($ascii))) + static::strlen($char)sprintf('=%02X', $ascii) with preset $charLen = 3

Added 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.

@gr8man gr8man force-pushed the refactor/email-prep-quoted-printable branch from 4f43143 to 2af2294 Compare June 28, 2026 22:31
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.

2 participants