NAME
Catalyst::Seal::Finalize - the encoding decision, decided once per content type
DESCRIPTION
The encoding decision
Catalyst::finalize_encoding costs 49 us per request to decide that a text/plain body does not need encoding. It reaches that answer by calling content_type four times and content_type_charset three times, each of which re-parses the same header string, plus encodable_response, which calls both again.
Every input is a string:
$res->content_type
$res->content_encoding
$res->encodable_content_type the regex the type is matched against
$c->encoding && $c->encoding->mime_name
so the answer is a pure function of those four, and an application emits a handful of distinct content types in its life.
The memo is keyed on the encoding's mime name rather than on the encoding object, because $c->encoding($enc) is a documented per-request call and $c->clear_encoding sets it to undef. Keying on the name cannot go stale.
Response::DESTROY
Not in the plan for this phase, and found by profiling it. Moose's inlined destructor for Catalyst::Response builds two closures and enters Try::Tiny::try on every response destroyed, to call a four line DEMOLISH that usually returns immediately. 17 us per request, of which the DEMOLISH is 1.3.
The other classes in the tree with an inlined destructor, Catalyst::Request, the context class, Catalyst::Log and Catalyst::Stats, have no DEMOLISH at all, so theirs are already no-ops costing 0.2 us and are left alone.
AUTHOR
LNATION <email@lnation.org>
LICENSE AND COPYRIGHT
This software is Copyright (c) 2026 by LNATION <email@lnation.org>.
This is free software, licensed under:
The Artistic License 2.0 (GPL Compatible)