Bugzilla – Attachment 140062 Details for
Bug 31455
Batch modification tool orders found items by itemnumber
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 31455: (QA follow-up) Make table creation O(N)
Bug-31455-QA-follow-up-Make-table-creation-ON.patch (text/plain), 1.92 KB, created by
Joonas Kylmälä
on 2022-09-01 19:47:11 UTC
(
hide
)
Description:
Bug 31455: (QA follow-up) Make table creation O(N)
Filename:
MIME Type:
Creator:
Joonas Kylmälä
Created:
2022-09-01 19:47:11 UTC
Size:
1.92 KB
patch
obsolete
>From 97d622bbcf8b212156bdcf7644f23f8f2d4fde30 Mon Sep 17 00:00:00 2001 >From: =?UTF-8?q?Joonas=20Kylm=C3=A4l=C3=A4?= <joonas.kylmala@iki.fi> >Date: Thu, 1 Sep 2022 19:45:25 +0000 >Subject: [PATCH] Bug 31455: (QA follow-up) Make table creation O(N) >MIME-Version: 1.0 >Content-Type: text/plain; charset=UTF-8 >Content-Transfer-Encoding: 8bit > >We can insert the indices before the main loop to a hash, >this way we don't have to look up during each loop iteration >the index from an array which in the worst case might take O(N) >thus making the total time complexity O(N^2). > >Signed-off-by: Joonas Kylmälä <joonas.kylmala@iki.fi> >--- > Koha/UI/Table/Builder/Items.pm | 6 ++---- > 1 file changed, 2 insertions(+), 4 deletions(-) > >diff --git a/Koha/UI/Table/Builder/Items.pm b/Koha/UI/Table/Builder/Items.pm >index 34b3cfcffd..615d210871 100644 >--- a/Koha/UI/Table/Builder/Items.pm >+++ b/Koha/UI/Table/Builder/Items.pm >@@ -19,7 +19,6 @@ use Modern::Perl; > use List::MoreUtils qw( uniq ); > use C4::Biblio qw( GetMarcStructure GetMarcFromKohaField IsMarcStructureInternal ); > use Koha::Items; >-use List::MoreUtils qw(first_index); > > =head1 NAME > >@@ -72,16 +71,15 @@ Use it with: > > sub build_table { > my ( $self, $params ) = @_; >- my @itemnumbers = @{ $self->{itemnumbers} }; >+ my %itemnumbers_to_idx = map { $self->{itemnumbers}->[$_] => $_ } 0..$#{$self->{itemnumbers}}; > my $items = Koha::Items->search( { itemnumber => $self->{itemnumbers} } ); > > my @items; > while ( my $item = $items->next ) { > my $item_info = $item->columns_to_str; >- my $index = first_index { $_ eq $item->itemnumber } @itemnumbers; > $item_info = { > %$item_info, >- index => $index, >+ index => $itemnumbers_to_idx{$item->itemnumber}, > biblio => $item->biblio, > safe_to_delete => $item->safe_to_delete, > holds => $item->biblio->holds->count, >-- >2.30.2
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 31455
:
140052
|
140059
|
140061
| 140062