Bug 15968 - Unnecessary loop in C4::Templates
Summary: Unnecessary loop in C4::Templates
Status: CLOSED FIXED
Alias: None
Product: Koha
Classification: Unclassified
Component: Architecture, internals, and plumbing (show other bugs)
Version: master
Hardware: All All
: P5 - low normal (vote)
Assignee: Jonathan Druart
QA Contact: Marcel de Rooy
URL:
Keywords:
Depends on:
Blocks: 15342
  Show dependency treegraph
 
Reported: 2016-03-03 11:35 UTC by Jonathan Druart
Modified: 2017-06-14 22:10 UTC (History)
3 users (show)

See Also:
Change sponsored?: ---
Patch complexity: Small patch
Who signed the patch off:
Text to go in the release notes:
Version(s) released in:


Attachments
Bug 15968: Unnecessary loop in C4::Templates (1.20 KB, patch)
2016-03-03 11:36 UTC, Jonathan Druart
Details | Diff | Splinter Review
Bug 15968: Unnecessary loop in C4::Templates (1.43 KB, patch)
2016-03-03 16:29 UTC, Frédéric Demians
Details | Diff | Splinter Review
Bug 15968: Unnecessary loop in C4::Templates (1.53 KB, patch)
2016-03-04 11:08 UTC, Marcel de Rooy
Details | Diff | Splinter Review

Note You need to log in before you can comment on or make changes to this bug.
Description Jonathan Druart 2016-03-03 11:35:01 UTC
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.
Comment 1 Jonathan Druart 2016-03-03 11:36:35 UTC Comment hidden (obsolete)
Comment 2 Frédéric Demians 2016-03-03 16:29:42 UTC Comment hidden (obsolete)
Comment 3 Marcel de Rooy 2016-03-04 11:08:21 UTC
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>
Comment 4 Marcel de Rooy 2016-03-04 11:09:22 UTC
Great test plan :) And the speed is back !
Comment 5 Brendan Gallagher 2016-03-07 17:20:56 UTC
Pushed to Master - Should be in the May 2016 release.  Thanks!
Comment 6 Julian Maurice 2016-03-14 09:24:39 UTC
Patch pushed to 3.22.x, will be in 3.22.5