[LON-CAPA-cvs] cvs: loncom /lonnet/perl lonnet.pm

raeburn raeburn at source.lon-capa.org
Thu Oct 15 14:09:10 EDT 2020


raeburn		Thu Oct 15 18:09:10 2020 EDT

  Modified files:              
    /loncom/lonnet/perl	lonnet.pm 
  Log:
  - Make &get_commblock_resources() faster by replacing retrieveResources()
    with an iterator that looks for the first answerable resource in the map.
  
  
Index: loncom/lonnet/perl/lonnet.pm
diff -u loncom/lonnet/perl/lonnet.pm:1.1427 loncom/lonnet/perl/lonnet.pm:1.1428
--- loncom/lonnet/perl/lonnet.pm:1.1427	Tue Oct  6 17:26:15 2020
+++ loncom/lonnet/perl/lonnet.pm	Thu Oct 15 18:09:10 2020
@@ -1,7 +1,7 @@
 # The LearningOnline Network
 # TCP networking package
 #
-# $Id: lonnet.pm,v 1.1427 2020/10/06 17:26:15 raeburn Exp $
+# $Id: lonnet.pm,v 1.1428 2020/10/15 18:09:10 raeburn Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -8763,14 +8763,21 @@
                             if ($mapsymb) {
                                 if (ref($navmap)) {
                                     my $mapres = $navmap->getBySymb($mapsymb);
-                                    @to_test = $mapres->retrieveResources($mapres,undef,0,0,0,1);
-                                    foreach my $res (@to_test) {
-                                        my $symb = $res->symb();
-                                        next if ($symb eq $mapsymb);
-                                        if ($symb ne '') {
+                                    if (ref($mapres)) {
+                                        my $first = $mapres->map_start();
+                                        my $finish = $mapres->map_finish();
+                                        my $it = $navmap->getIterator($first,$finish,undef,0,0);
+                                        my $res;
+                                        while ($res = $it->next(undef,1)) {
+                                            next unless (ref($res));
+                                            my $symb = $res->symb();
+                                            next if (($symb eq $mapsymb) || ($symb eq ''));
                                             @interval=&EXT("resource.0.interval",$symb);
                                             if ($interval[1] eq 'map') {
-                                                last;
+                                                if ($res->answerable()) {
+                                                    push(@to_test,$res);
+                                                    last;
+                                                }
                                             }
                                         }
                                     }




More information about the LON-CAPA-cvs mailing list