[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm
albertel
lon-capa-cvs@mail.lon-capa.org
Thu, 04 Jul 2002 15:56:17 -0000
albertel Thu Jul 4 11:56:17 2002 EDT
Modified files:
/loncom/lonnet/perl lonnet.pm
Log:
- no need to reparse the string each time, just store the returned hash
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.250 loncom/lonnet/perl/lonnet.pm:1.251
--- loncom/lonnet/perl/lonnet.pm:1.250 Thu Jul 4 11:47:18 2002
+++ loncom/lonnet/perl/lonnet.pm Thu Jul 4 11:56:17 2002
@@ -1,7 +1,7 @@
# The LearningOnline Network
# TCP networking package
#
-# $Id: lonnet.pm,v 1.250 2002/07/04 15:47:18 albertel Exp $
+# $Id: lonnet.pm,v 1.251 2002/07/04 15:56:17 albertel Exp $
#
# Copyright Michigan State University Board of Trustees
#
@@ -2278,25 +2278,17 @@
if (time-$courseresdatacache{$hashid.'.time'}>300) { $dodump=1; }
}
if ($dodump) {
- my $coursehom=&homeserver($coursenum,$coursedomain);
- if ($coursehom) {
- my $dumpreply=&reply('dump:'.$coursedomain.':'.$coursenum.
- ':resourcedata:.',$coursehom);
- if ($dumpreply!~/^error\:/) {
- $courseresdatacache{$hashid.'.time'}=time;
- $courseresdatacache{$hashid}=$dumpreply;
- }
+ my %dumpreply=&dump('resourcedata',$coursedomain,$coursenum);
+ my ($tmp) = keys(%dumpreply);
+ if ($tmp !~ /^(con_lost|error|no_such_host)/i) {
+ $courseresdatacache{$hashid.'.time'}=time;
+ $courseresdatacache{$hashid}=\%dumpreply;
}
}
- my @pairs=split(/\&/,$courseresdatacache{$hashid});
- my %returnhash=();
- foreach (@pairs) {
- my ($key,$value)=split(/=/,$_);
- $returnhash{unescape($key)}=unescape($value);
- }
- my $item;
- foreach $item (@which) {
- if ($returnhash{$item}) { return $returnhash{$item}; }
+ foreach my $item (@which) {
+ if ($courseresdatacache{$hashid}->{$item}) {
+ return $courseresdatacache{$hashid}->{$item};
+ }
}
return '';
}