[LON-CAPA-cvs] cvs: loncom /interface/spreadsheet studentcalc.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Fri, 13 May 2005 20:30:15 -0000
albertel Fri May 13 16:30:15 2005 EDT
Modified files:
/loncom/interface/spreadsheet studentcalc.pm
Log:
- shave another 0.5 seconds per student
Index: loncom/interface/spreadsheet/studentcalc.pm
diff -u loncom/interface/spreadsheet/studentcalc.pm:1.30 loncom/interface/spreadsheet/studentcalc.pm:1.31
--- loncom/interface/spreadsheet/studentcalc.pm:1.30 Thu Apr 7 02:56:23 2005
+++ loncom/interface/spreadsheet/studentcalc.pm Fri May 13 16:30:14 2005
@@ -1,5 +1,5 @@
#
-# $Id: studentcalc.pm,v 1.30 2005/04/07 06:56:23 albertel Exp $
+# $Id: studentcalc.pm,v 1.31 2005/05/13 20:30:14 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -101,22 +101,29 @@
for my $sequence ($navmap->getById('0.0'), @all_sequences) {
if ($navmap->hasResource($sequence,sub { shift->is_problem(); }, 0)){
push(@Sequences,$sequence);
+ &get_resources($sequence);
}
}
}
+my %res_memoize;
sub get_resources {
my ($seq) = @_;
+ if (exists($res_memoize{$seq->symb()})) {
+ return @{$res_memoize{$seq->symb()}};
+ }
return () if (! defined($navmap) || ! ref($navmap));
my @resources = $navmap->retrieveResources($seq,
sub { shift->is_problem(); },
0,0,0);
+ $res_memoize{$seq->symb()}=\@resources;
return @resources;
}
sub clear_package {
undef(@Sequences);
undef(%Exportrows);
+ undef(%res_memoize);
&Apache::assesscalc::clear_package();
}