Bugzilla – Attachment 60472 Details for
Bug 17941
CanBookBeRenewed is very inefficient/slow
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 17941 avoid scanning the full cartesian product
Bug-17941-avoid-scanning-the-full-cartesian-produc.patch (text/plain), 2.24 KB, created by
Mark Tompsett
on 2017-02-20 16:10:23 UTC
(
hide
)
Description:
Bug 17941 avoid scanning the full cartesian product
Filename:
MIME Type:
Creator:
Mark Tompsett
Created:
2017-02-20 16:10:23 UTC
Size:
2.24 KB
patch
obsolete
>From 457de30d8b552bab9e80723a5f70fc168c5bf09d Mon Sep 17 00:00:00 2001 >From: Francesco Rivetti <oha@oha.it> >Date: Tue, 14 Feb 2017 11:13:51 +0100 >Subject: [PATCH] Bug 17941 avoid scanning the full cartesian product > >when a item match a borrower, there is no point in checking the >other borrowers > >Signed-off-by: Mark Tompsett <mtompset@hotmail.com> >--- > C4/Circulation.pm | 29 ++++++++++++++--------------- > 1 file changed, 14 insertions(+), 15 deletions(-) > >diff --git a/C4/Circulation.pm b/C4/Circulation.pm >index e2cd626..b6ca23d 100644 >--- a/C4/Circulation.pm >+++ b/C4/Circulation.pm >@@ -2677,24 +2677,23 @@ sub CanBookBeRenewed { > # can be filled with available items. We can get the union of the sets simply > # by pushing all the elements onto an array and removing the duplicates. > my @reservable; >- foreach my $b (@borrowernumbers) { >- my ($borr) = C4::Members::GetMember( borrowernumber => $b); >- foreach my $i (@itemnumbers) { >- my $item = GetItem($i); >- if ( !IsItemOnHoldAndFound($i) >- && IsAvailableForItemLevelRequest( $item, $borr ) >- && CanItemBeReserved( $b, $i ) ) >- { >- push( @reservable, $i ); >+ my %borrowers; >+ ITEM: foreach my $i (@itemnumbers) { >+ my $item = GetItem($i); >+ next if IsItemOnHoldAndFound($i); >+ for my $b (@borrowernumbers) { >+ my $borr = $borrowers{$b}//= C4::Members::GetMember(borrowernumber => $b); >+ next unless IsAvailableForItemLevelRequest($item, $borr); >+ next unless CanItemBeReserved($b,$i); >+ >+ push @reservable, $i; >+ if (@reservable >= @borrowernumbers) { >+ $resfound = 0; >+ last ITEM; > } >+ last; > } > } >- >- @reservable = uniq(@reservable); >- >- if ( @reservable >= @borrowernumbers ) { >- $resfound = 0; >- } > } > } > return ( 0, "on_reserve" ) if $resfound; # '' when no hold was found >-- >2.1.4
You cannot view the attachment while viewing its details because your browser does not support IFRAMEs.
View the attachment on a separate page
.
View Attachment As Diff
View Attachment As Raw
Actions:
View
|
Diff
|
Splinter Review
Attachments on
bug 17941
:
59740
|
60181
|
60184
|
60185
|
60186
|
60188
|
60189
|
60190
|
60191
|
60192
|
60457
|
60472
|
60473
|
60474
|
60544
|
60545
|
60546