Bugzilla – Attachment 153450 Details for
Bug 33745
Speed up Koha::Object attribute accessors
Home
|
New
|
Browse
|
Search
|
[?]
|
Reports
|
Help
|
New Account
|
Log In
[x]
|
Forgot Password
Login:
[x]
[patch]
Bug 33745: (QA follow-up) Remove goto
Bug-33745-QA-follow-up-Remove-goto.patch (text/plain), 1.98 KB, created by
Marcel de Rooy
on 2023-07-14 09:55:41 UTC
(
hide
)
Description:
Bug 33745: (QA follow-up) Remove goto
Filename:
MIME Type:
Creator:
Marcel de Rooy
Created:
2023-07-14 09:55:41 UTC
Size:
1.98 KB
patch
obsolete
>From c06d16815a47d92c48f653b40ea559b0ffb2f652 Mon Sep 17 00:00:00 2001 >From: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >Date: Fri, 14 Jul 2023 09:28:54 +0000 >Subject: [PATCH] Bug 33745: (QA follow-up) Remove goto >Content-Type: text/plain; charset=utf-8 > >Test plan: >Prove t/db_dependent/Koha >Run the benchmark (on BZ) again > >Signed-off-by: Marcel de Rooy <m.de.rooy@rijksmuseum.nl> >--- > Koha/Object.pm | 13 ++++++------- > 1 file changed, 6 insertions(+), 7 deletions(-) > >diff --git a/Koha/Object.pm b/Koha/Object.pm >index 13ef9acacd..f045169418 100644 >--- a/Koha/Object.pm >+++ b/Koha/Object.pm >@@ -900,16 +900,15 @@ The autoload method is used only to get and set values for an objects properties > =cut > > sub AUTOLOAD { >- my ($self) = @_; >+ my $self = shift; > > my $method = our $AUTOLOAD; > $method =~ s/.*://; > > my @columns = @{$self->_columns()}; >- # Using direct setter/getter like $item->barcode() or $item->barcode($barcode); > if ( grep { $_ eq $method } @columns ) { >- no strict 'refs'; >- *{$AUTOLOAD} = sub { >+ # Lazy definition of get/set accessors like $item->barcode; note that it contains $method >+ my $accessor = sub { > my $self = shift; > if ( @_ ) { > $self->_result()->set_column( $method, @_); >@@ -918,7 +917,9 @@ sub AUTOLOAD { > return $self->_result()->get_column( $method ); > } > }; >- goto &{$AUTOLOAD}; >+ no strict 'refs'; >+ *{$AUTOLOAD} = $accessor; >+ return $accessor->($self, @_); > } > > my @known_methods = qw( is_changed id in_storage get_column discard_changes make_column_dirty ); >@@ -928,8 +929,6 @@ sub AUTOLOAD { > show_trace => 1 > ) unless grep { $_ eq $method } @known_methods; > >- # Remove $self so that @_ now contain arguments only >- shift; > my $r = eval { $self->_result->$method(@_) }; > if ( $@ ) { > Koha::Exceptions::Object->throw( ref($self) . "::$method generated this error: " . $@ ); >-- >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 33745
:
151273
|
151274
|
151275
|
151290
|
153449
| 153450 |
153451
|
153452
|
153510
|
153525
|
153584
|
153586