Yes you can do quite a few things to that sub:
sub IsStrongMatch
{
# Return true if id2 is only top ranked match for id1
my $id1 = shift;
my $id2 = shift;
my $rC = shift;
for my $i1 ( keys %{$rC} )
{
next if $i1 == $id1;
foreach my $i2 ( sort { $rC->{$i1}->{$a} <=> $rC->{$i1}->{$b}
+} keys %{$rC->{$i1}} )
{
if ( $id2 == $i2 )
{
return 0;
}
last;
}
}
return 1;
}
A. You can remove the temporary variable
$i2, it isn't used anywhere in a subscope and
$_ can be used instead, that way you don't have to copy to a temp var.
B. You can use
@_[0-2] rather than shifting to temp variables, which is many more processes than needed.
C. You can return
undef rather than
0 rumor mill says this is a minor optimization.
Evan Carroll
www.EvanCarroll.com
Posts are HTML formatted. Put <p> </p> tags around your paragraphs. Put <code> </code> tags around your code and data!
Titles consisting of a single word are discouraged, and in most cases are disallowed outright.
Read Where should I post X? if you're not absolutely sure you're posting in the right place.
Please read these before you post! —
Posts may use any of the Perl Monks Approved HTML tags:
- a, abbr, b, big, blockquote, br, caption, center, col, colgroup, dd, del, details, div, dl, dt, em, font, h1, h2, h3, h4, h5, h6, hr, i, ins, li, ol, p, pre, readmore, small, span, spoiler, strike, strong, sub, summary, sup, table, tbody, td, tfoot, th, thead, tr, tt, u, ul, wbr
You may need to use entities for some characters, as follows. (Exception: Within code tags, you can put the characters literally.)
| |
For: |
|
Use: |
| & | | & |
| < | | < |
| > | | > |
| [ | | [ |
| ] | | ] |
Link using PerlMonks shortcuts! What shortcuts can I use for linking?
See Writeup Formatting Tips and other pages linked from there for more info.