diff libinterp/corefcn/conv2.cc @ 20918:6f0bd96f93c0

maint: Use new C++ archetype in more files. Place input validation first in files. Move declaration of retval down in function to be closer to point of usage. Eliminate else clause after if () error. Use "return ovl()" where it makes sense. * __dispatch__.cc, __dsearchn__.cc, __ichol__.cc, __lin_interpn__.cc, balance.cc, betainc.cc, bitfcns.cc, bsxfun.cc, cellfun.cc, colloc.cc, conv2.cc, daspk.cc, dasrt.cc, dassl.cc, data.cc, debug.cc, dirfns.cc, dlmread.cc, dot.cc, eig.cc, error.cc, fft.cc, fft2.cc, fftn.cc, file-io.cc, ov-type-conv.h: Use new C++ archetype in more files.
author Rik <rik@octave.org>
date Wed, 16 Dec 2015 15:00:31 -0800
parents 1142cf6abc0d
children 48b2ad5ee801
line wrap: on
line diff
--- a/libinterp/corefcn/conv2.cc	Wed Dec 16 17:09:44 2015 -0500
+++ b/libinterp/corefcn/conv2.cc	Wed Dec 16 15:00:31 2015 -0800
@@ -64,16 +64,15 @@
 @seealso{conv, convn}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  octave_value tmp;
   int nargin = args.length ();
+
+  if (nargin < 2 || nargin > 4)
+    print_usage ();
+
   std::string shape = "full";   // default
   bool separable = false;
   convn_type ct = convn_full;
 
-  if (nargin < 2 || nargin > 4)
-    print_usage ();
-
   if (nargin == 3)
     {
       if (args(2).is_string ())
@@ -99,10 +98,11 @@
   else
     error ("conv2: SHAPE type not valid");
 
+  octave_value retval;
+
   if (separable)
     {
       // If user requests separable, check first two params are vectors
-
       if (! (1 == args(0).rows () || 1 == args(0).columns ())
           || ! (1 == args(1).rows () || 1 == args(1).columns ()))
         error ("conv2: arguments must be vectors for separable option");
@@ -305,15 +305,14 @@
 @seealso{conv2, conv}\n\
 @end deftypefn")
 {
-  octave_value retval;
-  octave_value tmp;
   int nargin = args.length ();
-  std::string shape = "full";   // default
-  convn_type ct = convn_full;
 
   if (nargin < 2 || nargin > 3)
     print_usage ();
 
+  std::string shape = "full";   // default
+  convn_type ct = convn_full;
+
   if (nargin == 3)
     shape = args(2).xstring_value ("convn: SHAPE must be a string");
 
@@ -326,6 +325,8 @@
   else
     error ("convn: SHAPE type not valid");
 
+  octave_value retval;
+
   if (args(0).is_single_type () || args(1).is_single_type ())
     {
       if (args(0).is_complex_type () || args(1).is_complex_type ())