about summary refs log tree commit diff
path: root/src/rt/rust_exchange_alloc.cpp
diff options
context:
space:
mode:
authorHuon Wilson <dbau.pp+github@gmail.com>2013-07-28 01:16:30 +1000
committerHuon Wilson <dbau.pp+github@gmail.com>2013-08-04 19:46:52 +1000
commit8407ec9fedccdd410dee2bca67651ce245ed5cd3 (patch)
tree1169ef9f908506cbdfe415bbfe1d269f4afea6ec /src/rt/rust_exchange_alloc.cpp
parent44acdad5f8974206d871bb1134f67368bdb236ee (diff)
downloadrust-8407ec9fedccdd410dee2bca67651ce245ed5cd3.tar.gz
rust-8407ec9fedccdd410dee2bca67651ce245ed5cd3.zip
syntax: make #[deriving(TotalOrd)] lazy.
Previously it would call:

  f(sf1.cmp(&of1), f(sf2.cmp(&of2), ...))

(where s/of1 = 'self/other field 1', and f was
std::cmp::lexical_ordering)

This meant that every .cmp subcall got evaluated when calling a derived
TotalOrd.cmp.

This corrects this to use

   let test = sf1.cmp(&of1);
   if test == Equal {
      let test = sf2.cmp(&of2);
      if test == Equal {
        // ...
      } else {
        test
      }
   } else {
     test
   }

This gives a lexical ordering by short-circuiting on the first comparison
that is not Equal.
Diffstat (limited to 'src/rt/rust_exchange_alloc.cpp')
0 files changed, 0 insertions, 0 deletions