diff src/ov-base.cc @ 8345:c777f3ce02d8

smarter conversion lookup
author Jaroslav Hajek <highegg@gmail.com>
date Tue, 25 Nov 2008 14:04:55 +0100
parents f336dd8e96d0
children d254a21e0120
line wrap: on
line diff
--- a/src/ov-base.cc	Mon Nov 24 12:57:57 2008 -0500
+++ b/src/ov-base.cc	Tue Nov 25 14:04:55 2008 +0100
@@ -1150,9 +1150,26 @@
 	{
 	  octave_value tmp_rhs;
 
-	  octave_base_value::type_conv_fcn cf_rhs
+	  octave_base_value::type_conv_info cf_rhs
 	    = rhs.numeric_conversion_function ();
 
+	  octave_base_value::type_conv_info cf_this
+	    = numeric_conversion_function ();
+
+          // Try biased (one-sided) conversions first.
+          if (cf_rhs.type_id () >= 0
+              && (octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq,
+                                                           t_lhs, cf_rhs.type_id ())
+                  || octave_value_typeinfo::lookup_pref_assign_conv (t_lhs, 
+                                                                     cf_rhs.type_id ()) >= 0))
+            cf_this = 0;
+          else if (cf_this.type_id () >= 0
+                   && (octave_value_typeinfo::lookup_assign_op (octave_value::op_asn_eq,
+                                                                cf_this.type_id (), t_rhs)
+                       || octave_value_typeinfo::lookup_pref_assign_conv (cf_this.type_id (),
+                                                                          t_rhs) >= 0))
+            cf_rhs = 0;
+
 	  if (cf_rhs)
 	    {
 	      octave_base_value *tmp = cf_rhs (rhs.get_rep ());
@@ -1169,9 +1186,6 @@
 	  else
 	    tmp_rhs = rhs;
 
-	  octave_base_value::type_conv_fcn cf_this
-	    = numeric_conversion_function ();
-
 	  count++;
 	  octave_value tmp_lhs = octave_value (this);