Skip to content

Commit

Permalink
[src/core/Any-list.pm] be more forgiving
Browse files Browse the repository at this point in the history
In the min/max/minmax methods, even though we should technically expect to
get only -1, 0, or +1, we'll instead check for negative, zero, and positive.
This due to at least two reasons: (a) Postel's law, (b) it's faster :)
  • Loading branch information
Carl Masak committed Aug 27, 2010
1 parent 18189a2 commit 2740248
Showing 1 changed file with 6 additions and 6 deletions.
12 changes: 6 additions & 6 deletions src/core/Any-list.pm
Expand Up @@ -87,7 +87,7 @@ augment class Any {
$first-time = Bool::False;
next;
}
if $cmp($_, $min) == -1 {
if $cmp($_, $min) < 0 {
$min = $_;
}
}
Expand All @@ -108,7 +108,7 @@ augment class Any {
$first-time = Bool::False;
next;
}
if $cmp($_, $max) == 1 {
if $cmp($_, $max) > 0 {
$max = $_;
}
}
Expand Down Expand Up @@ -137,11 +137,11 @@ augment class Any {
$first-time = Bool::False;
next;
}
if $cmp($_.min, $min) == -1 {
if $cmp($_.min, $min) < 0 {
$min = $_;
$excludes_min = $_.excludes_min;
}
if $cmp($_.max, $max) == 1 {
if $cmp($_.max, $max) > 0 {
$max = $_;
$excludes_max = $_.excludes_max;
}
Expand All @@ -153,11 +153,11 @@ augment class Any {
$first-time = Bool::False;
next;
}
if $cmp($_, $min) == -1 {
if $cmp($_, $min) < 0 {
$min = $_;
$excludes_min = Bool::False;
}
if $cmp($_, $max) == 1 {
if $cmp($_, $max) > 0 {
$max = $_;
$excludes_max = Bool::False;
}
Expand Down

0 comments on commit 2740248

Please sign in to comment.