Mercurial > hg > octave-lojdl
changeset 17217:87ba70043bfc
Don't use ifelse in plot fcns to avoid unnecessary fcn evaluations.
* scripts/plot/area.m, scripts/plot/axis.m, scripts/plot/caxis.m,
scripts/plot/comet.m, scripts/plot/comet3.m, scripts/plot/compass.m,
scripts/plot/contour.m, scripts/plot/contour3.m, scripts/plot/contourf.m,
scripts/plot/cylinder.m, scripts/plot/ellipsoid.m, scripts/plot/errorbar.m,
scripts/plot/feather.m, scripts/plot/fill.m, scripts/plot/loglog.m,
scripts/plot/loglogerr.m, scripts/plot/mesh.m, scripts/plot/meshc.m,
scripts/plot/meshz.m, scripts/plot/pcolor.m, scripts/plot/pie.m,
scripts/plot/pie3.m, scripts/plot/plot.m, scripts/plot/plot3.m,
scripts/plot/polar.m, scripts/plot/private/__bar__.m,
scripts/plot/private/__ezplot__.m, scripts/plot/private/__stem__.m,
scripts/plot/quiver.m, scripts/plot/quiver3.m, scripts/plot/rectangle.m,
scripts/plot/ribbon.m, scripts/plot/rose.m, scripts/plot/scatter.m,
scripts/plot/scatter3.m, scripts/plot/semilogx.m, scripts/plot/semilogxerr.m,
scripts/plot/semilogy.m, scripts/plot/semilogyerr.m, scripts/plot/slice.m,
scripts/plot/sphere.m, scripts/plot/stairs.m, scripts/plot/surf.m,
scripts/plot/surfc.m, scripts/plot/surfl.m, scripts/plot/surfnorm.m,
scripts/time/datetick.m: Don't use ifelse in plot fcns to avoid unnecessary fcn
evaluations.
line wrap: on
line diff
--- a/scripts/plot/area.m +++ b/scripts/plot/area.m @@ -103,7 +103,10 @@ x = repmat (x(:), 1, columns (y)); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); htmp = __area__ (hax, x, y, bv, args{:});
--- a/scripts/plot/axis.m +++ b/scripts/plot/axis.m @@ -135,7 +135,10 @@ [hax, varargin, nargin] = __plt_get_axis_arg__ ("axis", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect if (isempty (hax)) hax = gca ();
--- a/scripts/plot/caxis.m +++ b/scripts/plot/caxis.m @@ -43,7 +43,10 @@ [hax, varargin, nargin] = __plt_get_axis_arg__ ("caxis", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect if (isempty (hax)) hax = gca ();
--- a/scripts/plot/comet.m +++ b/scripts/plot/comet.m @@ -57,7 +57,10 @@ p = varargin{3}; endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); limits = [min(x), max(x), min(y), max(y)];
--- a/scripts/plot/comet3.m +++ b/scripts/plot/comet3.m @@ -59,7 +59,10 @@ p = varargin{4}; endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); limits = [min(x), max(x), min(y), max(y), min(z), max(z)];
--- a/scripts/plot/compass.m +++ b/scripts/plot/compass.m @@ -99,7 +99,10 @@ ytmp - u * arrowsize / 3]; [r, p] = cart2pol (x, y); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); hlist = polar (r, p, line_spec);
--- a/scripts/plot/contour.m +++ b/scripts/plot/contour.m @@ -63,7 +63,10 @@ [hax, varargin] = __plt_get_axis_arg__ ("contour", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/contour3.m +++ b/scripts/plot/contour3.m @@ -65,7 +65,10 @@ [hax, varargin, nargin] = __plt_get_axis_arg__ ("contour3", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/contourf.m +++ b/scripts/plot/contourf.m @@ -64,7 +64,10 @@ [hax, varargin] = __plt_get_axis_arg__ ("contour", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/cylinder.m +++ b/scripts/plot/cylinder.m @@ -83,7 +83,10 @@ yy = y; zz = z; else - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/ellipsoid.m +++ b/scripts/plot/ellipsoid.m @@ -74,7 +74,10 @@ yy = y; zz = z; else - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/errorbar.m +++ b/scripts/plot/errorbar.m @@ -130,7 +130,10 @@ [hax, varargin] = __plt_get_axis_arg__ ("errorbar", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/feather.m +++ b/scripts/plot/feather.m @@ -98,7 +98,10 @@ y = [zeros(1, n); yend; ytmp + u * arrowsize / 3; yend; ... ytmp - u * arrowsize / 3]; - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); hlist = plot (x, y, line_spec, [1, n], [0, 0], line_spec);
--- a/scripts/plot/fill.m +++ b/scripts/plot/fill.m @@ -72,7 +72,10 @@ hlist = []; iargs = __find_patches__ (varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); old_nxtplt = get (hax, "nextplot");
--- a/scripts/plot/loglog.m +++ b/scripts/plot/loglog.m @@ -45,7 +45,10 @@ print_usage (); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/loglogerr.m +++ b/scripts/plot/loglogerr.m @@ -48,7 +48,10 @@ [hax, varargin] = __plt_get_axis_arg__ ("loglogerr", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/mesh.m +++ b/scripts/plot/mesh.m @@ -63,7 +63,10 @@ [hax, varargin, nargin] = __plt_get_axis_arg__ ("mesh", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/meshc.m +++ b/scripts/plot/meshc.m @@ -61,7 +61,10 @@ [hax, varargin, nargin] = __plt_get_axis_arg__ ("meshc", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/meshz.m +++ b/scripts/plot/meshz.m @@ -111,7 +111,10 @@ varargin(charidx) = c; endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); htmp = mesh (x, y, z, varargin{charidx:end});
--- a/scripts/plot/pcolor.m +++ b/scripts/plot/pcolor.m @@ -74,7 +74,10 @@ print_usage (); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); htmp = surface (x, y, z, c);
--- a/scripts/plot/pie.m +++ b/scripts/plot/pie.m @@ -60,7 +60,10 @@ print_usage (); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); htmp = __pie__ ("pie", hax, varargin{:});
--- a/scripts/plot/pie3.m +++ b/scripts/plot/pie3.m @@ -61,7 +61,10 @@ print_usage (); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); htmp = __pie__ ("pie3", hax, varargin{:});
--- a/scripts/plot/plot.m +++ b/scripts/plot/plot.m @@ -206,7 +206,10 @@ print_usage (); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); htmp = __plt__ ("plot", hax, varargin{:});
--- a/scripts/plot/plot3.m +++ b/scripts/plot/plot3.m @@ -109,7 +109,10 @@ print_usage (); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/polar.m +++ b/scripts/plot/polar.m @@ -49,7 +49,10 @@ print_usage (); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/private/__bar__.m +++ b/scripts/plot/private/__bar__.m @@ -149,7 +149,10 @@ yb = reshape (yb, [4, numel(yb) / 4 / ycols, ycols]); if (nargout < 2) - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/private/__ezplot__.m +++ b/scripts/plot/private/__ezplot__.m @@ -427,7 +427,10 @@ until (domain_ok) ## Now, actually call the correct plot function with valid data and domain. - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); if (iscontour)
--- a/scripts/plot/private/__stem__.m +++ b/scripts/plot/private/__stem__.m @@ -37,7 +37,10 @@ [x, y, z, dofill, llc, ls, mmc, ms, varargin] = ... check_stem_arg (have_z, varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); hold_state = get (hax, "nextplot");
--- a/scripts/plot/quiver.m +++ b/scripts/plot/quiver.m @@ -68,7 +68,10 @@ if (nargin < 2) print_usage (); else - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); htmp = __quiver__ (hax, false, varargin{:});
--- a/scripts/plot/quiver3.m +++ b/scripts/plot/quiver3.m @@ -71,7 +71,10 @@ if (nargin < 2) print_usage (); else - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); htmp = __quiver__ (hax, true, varargin{:});
--- a/scripts/plot/rectangle.m +++ b/scripts/plot/rectangle.m @@ -60,7 +60,10 @@ [hax, varargin] = __plt_get_axis_arg__ ("rectangle", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/ribbon.m +++ b/scripts/plot/ribbon.m @@ -76,7 +76,10 @@ endif endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/rose.m +++ b/scripts/plot/rose.m @@ -90,7 +90,10 @@ r(3:4:end, :) = nn; if (nargout < 2) - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); htmp = polar (th, r);
--- a/scripts/plot/scatter.m +++ b/scripts/plot/scatter.m @@ -75,7 +75,10 @@ if (nargin < 2) print_usage (); else - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/scatter3.m +++ b/scripts/plot/scatter3.m @@ -72,7 +72,10 @@ if (nargin < 2) print_usage (); else - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/semilogx.m +++ b/scripts/plot/semilogx.m @@ -45,7 +45,10 @@ print_usage (); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/semilogxerr.m +++ b/scripts/plot/semilogxerr.m @@ -50,7 +50,10 @@ [hax, varargin] = __plt_get_axis_arg__ ("semilogxerr", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/semilogy.m +++ b/scripts/plot/semilogy.m @@ -45,7 +45,10 @@ print_usage (); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/semilogyerr.m +++ b/scripts/plot/semilogyerr.m @@ -50,7 +50,10 @@ [hax, varargin] = __plt_get_axis_arg__ ("semilogyerr", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/slice.m +++ b/scripts/plot/slice.m @@ -133,7 +133,10 @@ error ("slice: dimensional mismatch for (XI, YI, ZI) or (SX, SY, SZ)"); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/sphere.m +++ b/scripts/plot/sphere.m @@ -71,7 +71,10 @@ yy = y; zz = z; else - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/stairs.m +++ b/scripts/plot/stairs.m @@ -74,7 +74,10 @@ if (nargout > 1) [h, xs, ys] = __stairs__ (false, varargin{:}); else - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax); [htmp, xxs, yys] = __stairs__ (true, varargin{:});
--- a/scripts/plot/surf.m +++ b/scripts/plot/surf.m @@ -62,7 +62,10 @@ [hax, varargin] = __plt_get_axis_arg__ ("surf", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/surfc.m +++ b/scripts/plot/surfc.m @@ -64,7 +64,10 @@ print_usage (); endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/surfl.m +++ b/scripts/plot/surfl.m @@ -136,7 +136,10 @@ endif endif - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/plot/surfnorm.m +++ b/scripts/plot/surfnorm.m @@ -114,7 +114,10 @@ nz = nz ./ len; if (nargout == 0) - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif unwind_protect hax = newplot (hax);
--- a/scripts/time/datetick.m +++ b/scripts/time/datetick.m @@ -35,7 +35,10 @@ [hax, varargin, nargin] = __plt_get_axis_arg__ ("datetick", varargin{:}); - oldfig = ifelse (isempty (hax), [], get (0, "currentfigure")); + oldfig = []; + if (isempty (hax)) + oldfig = get (0, "currentfigure"); + endif if (isempty (hax)) hax = gca (); endif