summaryrefslogtreecommitdiff
path: root/FS/FS/location_Mixin.pm
diff options
context:
space:
mode:
authorIvan Kohler <ivan@freeside.biz>2014-08-09 15:19:27 -0700
committerIvan Kohler <ivan@freeside.biz>2014-08-09 15:19:27 -0700
commitf9930edeaceb217a6503fa49078fcff2b588caf8 (patch)
treeb7627bbada0c78d2f8c9317201db215b60932484 /FS/FS/location_Mixin.pm
parentde7167ac01e77d08f1fdd05ba229eb87b2c67e6d (diff)
optimizations for large package lists, RT#28526
Diffstat (limited to 'FS/FS/location_Mixin.pm')
-rw-r--r--FS/FS/location_Mixin.pm17
1 files changed, 14 insertions, 3 deletions
diff --git a/FS/FS/location_Mixin.pm b/FS/FS/location_Mixin.pm
index d32b4a37c..b010374a9 100644
--- a/FS/FS/location_Mixin.pm
+++ b/FS/FS/location_Mixin.pm
@@ -11,9 +11,20 @@ Returns the location object, if any (see L<FS::cust_location>).
=cut
sub cust_location {
- my $self = shift;
+ my( $self, %opt ) = @_;
+
return '' unless $self->locationnum;
- qsearchs( 'cust_location', { 'locationnum' => $self->locationnum } );
+
+ return $opt{_cache}->{$self->locationnum}
+ if $opt{_cache} && $opt{_cache}->{$self->locationnum};
+
+ my $cust_location =
+ qsearchs( 'cust_location', { 'locationnum' => $self->locationnum } );
+
+ $opt{_cache}->{$self->locationnum} = $cust_location
+ if $opt{_cache};
+
+ $cust_location;
}
=item cust_location_or_main
@@ -25,7 +36,7 @@ L<FS::cust_location>), otherwise returns the customer (see L<FS::cust_main>).
sub cust_location_or_main {
my $self = shift;
- $self->cust_location || $self->cust_main;
+ $self->cust_location(@_) || $self->cust_main;
}
=item location_label [ OPTION => VALUE ... ]