@@ -428,32 +428,18 @@ impl branch_kind : cmp::Eq {
428
428
}
429
429
430
430
// Compiles a comparison between two things.
431
- fn trans_compare ( cx : block , op : ast :: binop , lhs : ValueRef ,
432
- _lhs_t : ty :: t , rhs : ValueRef , rhs_t : ty :: t ) -> Result {
433
- let _icx = cx. insn_ctxt ( "trans_compare " ) ;
431
+ fn compare_values ( cx : block , lhs : ValueRef , rhs : ValueRef , rhs_t : ty :: t ) ->
432
+ Result {
433
+ let _icx = cx. insn_ctxt ( "compare_values " ) ;
434
434
if ty:: type_is_scalar ( rhs_t) {
435
- let rs = compare_scalar_types ( cx, lhs, rhs, rhs_t, op ) ;
435
+ let rs = compare_scalar_types ( cx, lhs, rhs, rhs_t, ast :: eq ) ;
436
436
return rslt ( rs. bcx , rs. val ) ;
437
437
}
438
438
439
439
// Determine the operation we need.
440
- let llop = {
441
- match op {
442
- ast:: eq | ast:: ne => C_u8 ( abi:: cmp_glue_op_eq) ,
443
- ast:: lt | ast:: ge => C_u8 ( abi:: cmp_glue_op_lt) ,
444
- ast:: le | ast:: gt => C_u8 ( abi:: cmp_glue_op_le) ,
445
- _ => cx. tcx ( ) . sess . bug ( ~"trans_compare got non-comparison-op")
446
- }
447
- } ;
448
-
440
+ let llop = C_u8 ( abi:: cmp_glue_op_eq) ;
449
441
let cmpval = glue:: call_cmp_glue ( cx, lhs, rhs, rhs_t, llop) ;
450
-
451
- // Invert the result if necessary.
452
- match op {
453
- ast:: eq | ast:: lt | ast:: le => rslt ( cx, cmpval) ,
454
- ast:: ne | ast:: ge | ast:: gt => rslt ( cx, Not ( cx, cmpval) ) ,
455
- _ => cx. tcx ( ) . sess . bug ( ~"trans_compare got non-comparison-op")
456
- }
442
+ rslt ( cx, cmpval)
457
443
}
458
444
459
445
fn compile_submatch ( bcx : block , m : match_ , vals : ~[ ValueRef ] ,
@@ -663,15 +649,12 @@ fn compile_submatch(bcx: block, m: match_, vals: ~[ValueRef],
663
649
do with_scope_result ( bcx, None , ~"compare_scope") |bcx| {
664
650
match trans_opt ( bcx, opt) {
665
651
single_result(
666
- Result { bcx, val} ) =>
667
- {
668
- trans_compare ( bcx, ast:: eq, test_val,
669
- t, val, t)
652
+ Result { bcx, val} ) => {
653
+ compare_values ( bcx, test_val, val, t)
670
654
}
671
655
range_result(
672
656
Result { val : vbegin, _} ,
673
- Result { bcx, val : vend} ) =>
674
- {
657
+ Result { bcx, val : vend} ) => {
675
658
let Result { bcx, val : llge} =
676
659
compare_scalar_types ( bcx, test_val,
677
660
vbegin, t, ast:: ge) ;
0 commit comments