Mercurial > hg > octave-terminal
changeset 12784:c499d54796d6
Minor stylistic fixes to profiler code
author | Jordi Gutiérrez Hermoso <jordigh@gmail.com> |
---|---|
date | Thu, 14 Jul 2011 01:21:06 -0500 |
parents | ad9263d965dc |
children | 730d25ef02d1 |
files | src/profiler.cc |
diffstat | 1 files changed, 18 insertions(+), 27 deletions(-) [+] |
line wrap: on
line diff
--- a/src/profiler.cc +++ b/src/profiler.cc @@ -123,7 +123,7 @@ { const int n = times.size (); - Cell result (1, n); + Cell retval (1, n); int i = 0; for (timing_map::const_iterator p = times.begin (); p != times.end (); ++p) { @@ -132,11 +132,11 @@ entry.contents ("name") = octave_value (p->first); entry.contents ("time") = octave_value (p->second); - result (i++) = entry; + retval (i++) = entry; } assert (i == n); - return result; + return retval; } double @@ -168,28 +168,23 @@ Enable or disable the profiler data collection.\n\ @end deftypefn") { - // If there is an output argument, return current (if we change the old) - // status of the profiler. - octave_value_list result; - if (nargout > 0) - { - if (nargout > 1) - error ("profiler_enable: too many output arguments requested"); + octave_value_list retval; - result(0) = profiler.is_active (); - } - - // If there is an input argument, set the status. const int nargin = args.length (); if (nargin > 0) { if (nargin > 1) - error ("profiler_enable: too many arguments specified"); + { + print_usage (); + return retval; + } profiler.set_active (args(0).bool_value ()); } - return result; + retval(0) = profiler.is_active (); + + return retval; } DEFUN (profiler_reset, args, nargout, @@ -198,17 +193,15 @@ Clear all collected profiling data.\n\ @end deftypefn") { - octave_value_list result; + octave_value_list retval; const int nargin = args.length (); if (nargin > 0) - error ("profiler_reset: no arguments expected"); - if (nargout > 0) - error ("profiler_reset: no output argument possible"); + warning ("profiler_reset: ignoring extra arguments"); profiler.reset (); - return result; + return retval; } DEFUN (profiler_data, args, nargout, @@ -217,15 +210,13 @@ Query the timings collected by the profiler.\n\ @end deftypefn") { - octave_value_list result; + octave_value_list retval; const int nargin = args.length (); if (nargin > 0) - error ("profiler_data: no arguments expected"); - if (nargout != 1) - error ("profiler_reset: expected exactly one output argument"); + warning ("profiler_data: ignoring extra arguments"); - result(0) = profiler.get_data (); + retval(0) = profiler.get_data (); - return result; + return retval; }