Mercurial > octave
changeset 23760:b85a46745298
__isequal__.m: Add extra specialization for cellstr inputs for performance (bug #51403).
* __isequal__.m: Add extra specialization for cellstr inputs.
Move cell() command out of while loop for performance.
author | Guillaume Flandin |
---|---|
date | Mon, 10 Jul 2017 10:31:15 -0700 |
parents | f891afece80d |
children | 102049c83e7c |
files | scripts/general/private/__isequal__.m |
diffstat | 1 files changed, 14 insertions(+), 2 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/general/private/__isequal__.m Mon Jul 10 09:38:17 2017 -0400 +++ b/scripts/general/private/__isequal__.m Mon Jul 10 10:31:15 2017 -0700 @@ -117,14 +117,26 @@ t = __isequal__ (args{:}); endwhile + elseif (iscellstr (x) && all (cellfun (@iscellstr, varargin))) + ## Check that each element of a cellstr is equal. + l_x = numel (x); + idx = 0; + ## FIXME: It would be faster to use strcmp on whole cellstr arrays, + ## rather than element-by-element, but bug #51412 needs to be fixed. + while (t && idx < l_x) + idx += 1; + t = all (strcmp (x{idx}, [cellindexmat(varargin, idx){:}])); + endwhile + elseif (iscell (x)) ## Check that each element of a cell is equal. l_x = numel (x); idx = 0; + args = cell (1, 2+l_v); + args{1} = nans_compare_equal; while (t && idx < l_x) idx += 1; - args = cell (1, 2+l_v); - args(1:2) = {nans_compare_equal, x{idx}}; + args{2} = x{idx}; args(3:end) = [cellindexmat(varargin, idx){:}]; t = __isequal__ (args{:});