Mercurial > octave
diff libinterp/octave-value/ov.cc @ 20962:3aa293be0e8d
maint: Invert simple conditionals in if/else/error paradigm.
Invert conditional in if statement and place error next to if.
Delete else, and decrease code indent by 4.
* cellfun.cc, data.cc, debug.cc, dirfns.cc, dynamic-ld.cc, file-io.cc,
gl2ps-renderer.cc, graphics.cc, graphics.in.h, hex2num.cc, load-save.cc,
ls-mat-ascii.cc, ls-oct-text.cc, oct-hist.cc, oct-lvalue.cc, oct-map.cc,
toplev.cc, __init_fltk__.cc, ov-base-int.cc, ov-bool-mat.cc, ov-cell.cc,
ov-class.cc, ov-classdef.cc, ov-cx-mat.cc, ov-fcn-handle.cc, ov-flt-cx-mat.cc,
ov-flt-re-mat.cc, ov-oncleanup.cc, ov-re-mat.cc, ov-str-mat.cc, ov-struct.cc,
ov-usr-fcn.cc, ov.cc, pt-arg-list.cc, pt-assign.cc, pt-colon.cc, pt-eval.cc,
pt-exp.cc:
Invert conditional in if statement and place error next to if.
Delete else, and decrease code indent by 4.
author | Rik <rik@octave.org> |
---|---|
date | Tue, 22 Dec 2015 10:29:22 -0800 |
parents | 77f5591878bf |
children | a5b500efca9f |
line wrap: on
line diff
--- a/libinterp/octave-value/ov.cc Tue Dec 22 07:43:44 2015 -0500 +++ b/libinterp/octave-value/ov.cc Tue Dec 22 10:29:22 2015 -0800 @@ -1420,16 +1420,14 @@ if (op != op_asn_eq) { - if (is_defined ()) - { - octave_value t = subsref (type, idx); - - binary_op binop = op_eq_to_binary_op (op); - - t_rhs = do_binary_op (binop, t, rhs); - } - else + if (! is_defined ()) error ("in computed assignment A(index) OP= X, A must be defined first"); + + octave_value t = subsref (type, idx); + + binary_op binop = op_eq_to_binary_op (op); + + t_rhs = do_binary_op (binop, t, rhs); } *this = subsasgn (type, idx, t_rhs); @@ -2441,27 +2439,25 @@ octave_value meth = symbol_table::find_method ("colon", dispatch_type); - if (meth.is_defined ()) + if (! meth.is_defined ()) + error ("colon method not defined for %s class", dispatch_type.c_str ()); + + octave_value_list args; + + if (increment.is_defined ()) { - octave_value_list args; - - if (increment.is_defined ()) - { - args(2) = limit; - args(1) = increment; - } - else - args(1) = limit; - - args(0) = base; - - octave_value_list tmp = feval (meth.function_value (), args, 1); - - if (tmp.length () > 0) - retval = tmp(0); + args(2) = limit; + args(1) = increment; } else - error ("colon method not defined for %s class", dispatch_type.c_str ()); + args(1) = limit; + + args(0) = base; + + octave_value_list tmp = feval (meth.function_value (), args, 1); + + if (tmp.length () > 0) + retval = tmp(0); } else {