[LON-CAPA-cvs] cvs: loncom / lond

matthew lon-capa-cvs@mail.lon-capa.org
Mon, 30 Sep 2002 21:38:18 -0000


matthew		Mon Sep 30 17:38:18 2002 EDT

  Modified files:              
    /loncom	lond 
  Log:
  Rewritten to speed up 'dump' calls with no regular expression.
  Use while ... each instead of foreach.
  Do not unescape anything or use eval if the regular expression is '.'.
  Use chop instead of a regular expression to remove trailing '&'.
  One enhancement that might speed up the statistics page is removing the
  call to 'eval'.
  
  
Index: loncom/lond
diff -u loncom/lond:1.99 loncom/lond:1.100
--- loncom/lond:1.99	Thu Sep 19 22:04:07 2002
+++ loncom/lond	Mon Sep 30 17:38:18 2002
@@ -2,7 +2,7 @@
 # The LearningOnline Network
 # lond "LON Daemon" Server (port "LOND" 5663)
 #
-# $Id: lond,v 1.99 2002/09/20 02:04:07 foxr Exp $
+# $Id: lond,v 1.100 2002/09/30 21:38:18 matthew Exp $
 #
 # Copyright Michigan State University Board of Trustees
 #
@@ -1224,21 +1224,25 @@
 		       } else {
                           $regexp='.';
 		       }
-                       my $proname=propath($udom,$uname);
                        my $qresult='';
-      if (tie(%hash,'GDBM_File',"$proname/$namespace.db",&GDBM_READER,0640)) {
+                       my $proname=propath($udom,$uname);
+    if (tie(%hash,'GDBM_File',"$proname/$namespace.db",&GDBM_READER(),0640)) {
                            study($regexp);
-                           foreach $key (keys %hash) {
-                               my $unescapeKey = &unescape($key);
-                               if (eval('$unescapeKey=~/$regexp/')) {
-                                  $qresult.="$key=$hash{$key}&";
-                              }
+                           while (($key,$value) = each(%hash)) {
+                               if ($regexp eq '.') {
+                                   $qresult.=$key.'='.$value.'&';
+                               } else {
+                                   my $unescapeKey = &unescape($key);
+                                   if (eval('$unescapeKey=~/$regexp/')) {
+                                       $qresult.="$key=$value&";
+                                   }
+                               }
                            }
-			   if (untie(%hash)) {
-		              $qresult=~s/\&$//;
-                              print $client "$qresult\n";
+                           if (untie(%hash)) {
+                               chop($qresult);
+                               print $client "$qresult\n";
                            } else {
-                              print $client "error:$!\n";
+                               print $client "error:$!\n";
                            }
                        } else {
                            print $client "error:$!\n";