Summary: | Unnecessary loop in C4::Templates | ||
---|---|---|---|
Product: | Koha | Reporter: | Jonathan Druart <jonathan.druart> |
Component: | Architecture, internals, and plumbing | Assignee: | Jonathan Druart <jonathan.druart> |
Status: | CLOSED FIXED | QA Contact: | Marcel de Rooy <m.de.rooy> |
Severity: | normal | ||
Priority: | P5 - low | CC: | brendan, julian.maurice, m.de.rooy |
Version: | Main | ||
Hardware: | All | ||
OS: | All | ||
Change sponsored?: | --- | Patch complexity: | Small patch |
Documentation contact: | Documentation submission: | ||
Text to go in the release notes: | Version(s) released in: | ||
Bug Depends on: | |||
Bug Blocks: | 15342 | ||
Attachments: |
Bug 15968: Unnecessary loop in C4::Templates
Bug 15968: Unnecessary loop in C4::Templates Bug 15968: Unnecessary loop in C4::Templates |
Description
Jonathan Druart
2016-03-03 11:35:01 UTC
Created attachment 48617 [details] [review] Bug 15968: Unnecessary loop in C4::Templates From C4::Templates::output # add variables set via param to $vars for processing for my $k ( keys %{ $self->{VARS} } ) { $vars->{$k} = $self->{VARS}->{$k}; } This loop is not necessary, we could do the same with $vars = { %$vars, %{ $self->{VARS} } }; After a quick benchmark, it gains 100 microseconds when we pass 170 vars to the template. Test plan: Do some clicks on the interface, everything should be ok. Created attachment 48633 [details] [review] Bug 15968: Unnecessary loop in C4::Templates From C4::Templates::output # add variables set via param to $vars for processing for my $k ( keys %{ $self->{VARS} } ) { $vars->{$k} = $self->{VARS}->{$k}; } This loop is not necessary, we could do the same with $vars = { %$vars, %{ $self->{VARS} } }; After a quick benchmark, it gains 100 microseconds when we pass 170 vars to the template. Test plan: Do some clicks on the interface, everything should be ok. Signed-off-by: Frédéric Demians <f.demians@tamil.fr> Perl idiosyncratic way of merging hash, clearer, if not quicker (not verified) Created attachment 48676 [details] [review] Bug 15968: Unnecessary loop in C4::Templates From C4::Templates::output # add variables set via param to $vars for processing for my $k ( keys %{ $self->{VARS} } ) { $vars->{$k} = $self->{VARS}->{$k}; } This loop is not necessary, we could do the same with $vars = { %$vars, %{ $self->{VARS} } }; After a quick benchmark, it gains 100 microseconds when we pass 170 vars to the template. Test plan: Do some clicks on the interface, everything should be ok. Signed-off-by: Frédéric Demians <f.demians@tamil.fr> Perl idiosyncratic way of merging hash, clearer, if not quicker (not verified) Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> Great test plan :) And the speed is back ! Pushed to Master - Should be in the May 2016 release. Thanks! Patch pushed to 3.22.x, will be in 3.22.5 |