Mercurial > hg > octave-avbm
changeset 16221:51b13fe45a94
unique.m: Avoid recursion in checking input arguments.
* scripts/set/unique.m: Don't call unique on unique's own input arguments.
Use built-in functions rather than call out to ismember m-file for performance.
author | Rik <rik@octave.org> |
---|---|
date | Thu, 07 Mar 2013 12:51:02 -0800 |
parents | 080990a47b69 |
children | caf4f386aaab |
files | scripts/set/unique.m |
diffstat | 1 files changed, 9 insertions(+), 6 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/set/unique.m +++ b/scripts/set/unique.m @@ -51,14 +51,17 @@ if (nargin > 1) ## parse options if (iscellstr (varargin)) - varargin = unique (varargin); - optfirst = ismember ("first", varargin); - optlast = ismember ("last", varargin); - optrows = ismember ("rows", varargin); + optfirst = strcmp ("first", varargin); + optlast = strcmp ("last", varargin); + optrows = strcmp ("rows", varargin); + if (! all (optfirst | optlast | optrows)) + error ("unique: invalid option"); + endif + optfirst = any (optfirst); + optlast = any (optlast); + optrows = any (optrows); if (optfirst && optlast) error ('unique: cannot specify both "last" and "first"'); - elseif (optfirst + optlast + optrows != nargin-1) - error ("unique: invalid option"); endif else error ("unique: options must be strings");