🚀 go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: es.comp.os.linux.programacion
Article #14175

RE: [perl] �Hay alguna forma de optimizar este bucle?

#14175
From: Jesus
Date: Wed, 29 Nov 2000 00:00
49 lines
2676 bytes
Hola a ver que se puede decir:
>. Tengo que hacer un bucle comprobando si en el hash %subject_hash
> se da algunas de las expresiones regulares de @regexp_list, pero cuando
> tengo que comprobar 7000 expresiones contra 6000 titulos se eterniza.
> Puede ser normal ya que son muchas comprobaciones pero quer�a saber si se
> puede optimizar algo. Gracias
>
>
Lo que creo un poco ineficiente es el (if ($hash == $tmp ) ) Si pones:
$insert=1 if $subject_hash{$tmp};# lo que estas haciendo es ver si existe un
valor con esa clave directamente, las llaves on unicas
Esta instrucci�n creo que te ahorra el primer bucle, y adem�s no que haces
con (--$i &15)

Bueno espero que te sirva.


> foreach $hash (sort keys %subject_hash) {  #�Por que ordenar?
>     $_ = $subject_hash{$hash}; (Sobra)
>     if (!(--$i & 15)) { # usa unless
>         print gettext("There are"), " $i ", gettext("messages left"),
"\n"; # �que es gettext?Para que sirve?Sobra?
>     }
>     foreach $key (@regexp_list) {
> ��������
>         if (/$key/i) {
>             $insert=0;
>             foreach $tmp ( @articles_to_get_list) {
>                 if ($hash == $tmp )

>                     $insert=1;
>                     break;
>                 }
>             }
>             if ($insert==0) {
>                 push (@articles_to_get_list, $hash);
>                 print gettext("Will get article number"), " $hash ",
>                       gettext("with subject"), " $_\n";
>             }
>         }
>     }
> }
>
> --
>   musg0 @ irc                     http://personales.jet.es/olsago/
>     _-(_)-  _-(_)-  _-( )-   (o_    _-(_)-  _-(_)-  _-(_)-  _-(_)-
>   `(___)  `(___)  `(___)     //\  `(___)  `(___)  `(___)  `(___)
>    // \\   // \\   // \\     V_/   // \\   // \\   // \\   // \\
> "Like penguins among sheeps we live." -=[Debian GNU/Linux Woody]=-
Technical Details
Message-ID: <19gV5.67739$k06.1801508@telenews.teleline.es>
Path: arc1-ca.pugleaf.net!unknown!not-for-mail
References: <slrn91m0va.cqa.gorka@conan.hondarribia.penguinpowered.com>

Show Full Headers
Complete Article Headers
X-Google-Language: SPANISH,ASCII
X-Google-Thread: f86c8,a085bb156a6e9970
X-Google-Attributes: gidf86c8,public
From: "Jesus" <calvin@micasa.org>
Subject: RE: [perl] �Hay alguna forma de optimizar este bucle?
Date: 2000/11/29
Message-ID: <19gV5.67739$k06.1801508@telenews.teleline.es>
X-Deja-AN: 699305151
References: <slrn91m0va.cqa.gorka@conan.hondarribia.penguinpowered.com>
X-Priority: 3
X-MimeOLE: Produced By Microsoft MimeOLE V5.00.2615.200
X-Complaints-To: newsmaster@company.com
X-Trace: telenews.teleline.es 975539901 62.83.20.193 (Thu, 30 Nov 2000 00:18:21 MET)
Organization: Typhoon Authentication Testing Club
X-MSMail-Priority: Normal
NNTP-Posting-Date: Thu, 30 Nov 2000 00:18:21 MET
Newsgroups: es.comp.os.linux.programacion