diff options
| author | Patrick Walton <pcwalton@mimiga.net> | 2012-09-07 18:53:14 -0700 |
|---|---|---|
| committer | Patrick Walton <pcwalton@mimiga.net> | 2012-09-10 12:48:42 -0700 |
| commit | 22b875770543ec1fe93cfb35fd07c692db5675e2 (patch) | |
| tree | 62004747db05cf0fb7d82b85133210c67e2c7bb3 /src/libcore | |
| parent | 9a15c50f6c3cec5320ef91f000142af0367890a4 (diff) | |
| download | rust-22b875770543ec1fe93cfb35fd07c692db5675e2.tar.gz rust-22b875770543ec1fe93cfb35fd07c692db5675e2.zip | |
rustc: Make shape-based compare glue never called for comparison operators.
Only called for string patterns.
Diffstat (limited to 'src/libcore')
| -rw-r--r-- | src/libcore/iter.rs | 2 | ||||
| -rw-r--r-- | src/libcore/str.rs | 17 | ||||
| -rw-r--r-- | src/libcore/task.rs | 40 |
3 files changed, 44 insertions, 15 deletions
diff --git a/src/libcore/iter.rs b/src/libcore/iter.rs index e9d6784136f..1e05965925c 100644 --- a/src/libcore/iter.rs +++ b/src/libcore/iter.rs @@ -179,7 +179,7 @@ pure fn min<A:Copy Ord,IA:BaseIter<A>>(self: IA) -> A { } } -pure fn max<A:Copy,IA:BaseIter<A>>(self: IA) -> A { +pure fn max<A:Copy Ord,IA:BaseIter<A>>(self: IA) -> A { match do foldl::<A,Option<A>,IA>(self, None) |a, b| { match a { Some(a_) if a_ > b => { diff --git a/src/libcore/str.rs b/src/libcore/str.rs index ca96090ebd4..66ef6e001b7 100644 --- a/src/libcore/str.rs +++ b/src/libcore/str.rs @@ -769,28 +769,17 @@ pure fn lt(a: &str, b: &str) -> bool { /// Bytewise less than or equal pure fn le(a: &str, b: &str) -> bool { - let (a_len, b_len) = (a.len(), b.len()); - let mut end = uint::min(a_len, b_len); - - let mut i = 0; - while i < end { - let (c_a, c_b) = (a[i], b[i]); - if c_a < c_b { return true; } - if c_a > c_b { return false; } - i += 1; - } - - return a_len <= b_len; + !lt(b, a) } /// Bytewise greater than or equal pure fn ge(a: &str, b: &str) -> bool { - !lt(b, a) + !lt(a, b) } /// Bytewise greater than pure fn gt(a: &str, b: &str) -> bool { - !le(b, a) + !le(a, b) } impl &str: Eq { diff --git a/src/libcore/task.rs b/src/libcore/task.rs index bee810fceba..ced39ef067b 100644 --- a/src/libcore/task.rs +++ b/src/libcore/task.rs @@ -158,6 +158,46 @@ enum SchedMode { PlatformThread } +impl SchedMode : cmp::Eq { + pure fn eq(&&other: SchedMode) -> bool { + match self { + SingleThreaded => { + match other { + SingleThreaded => true, + _ => false + } + } + ThreadPerCore => { + match other { + ThreadPerCore => true, + _ => false + } + } + ThreadPerTask => { + match other { + ThreadPerTask => true, + _ => false + } + } + ManualThreads(e0a) => { + match other { + ManualThreads(e0b) => e0a == e0b, + _ => false + } + } + PlatformThread => { + match other { + PlatformThread => true, + _ => false + } + } + } + } + pure fn ne(&&other: SchedMode) -> bool { + !self.eq(other) + } +} + /** * Scheduler configuration options * |
