]> Sergey Matveev's repositories - public-inbox.git/commit
config: config_fh_parse: micro-optimize
authorEric Wong <e@80x24.org>
Wed, 23 Dec 2020 08:38:52 +0000 (08:38 +0000)
committerEric Wong <e@80x24.org>
Wed, 23 Dec 2020 23:46:44 +0000 (23:46 +0000)
commita05445fb400108e60ede7d377cf3b26a0392eb24
tree6e21bab9bb8155cf9b764e8c5c91754e94be28bd
parent80424a6a72dbe2b1ea7ba9bfba8f273e4da385a7
config: config_fh_parse: micro-optimize

We can avoid a slow regexp capture and instead and rely on
rindex + substr to extract the section from the config file.

Then we use the defined-or-assignment (//=) operator combined
with the documented return value of `push' to ensure @section_order
is unique without repeating a hash lookup.

Finally, we avoid short-lived variables inside the loop and
declare them subroutine-wide to knock a teeny bit of allocation
time.

Combined, these optimizations bring the ~1.22s
PublicInbox::Config->new time down to ~0.98s with 50K inboxes.
lib/PublicInbox/Config.pm