Mercurial > hg > octave-nkf
comparison scripts/help/doc_cache_create.m @ 17386:6dbc866379e2
Replace cellfun() occurrences with faster code where possible.
* scripts/help/doc_cache_create.m: Use built-in "isclass" rather than ischar.
Use addpath and rmpath with multiple inputs rather than cellfun.
* scripts/image/imformats.m: Use isfield with cell string list rather
than cellfun.
* scripts/image/private/__imread__.m: Use ismember to replace cellfun/strcmpi
combo.
* scripts/miscellaneous/what.m: Re-order if/elseif tree.
* scripts/pkg/private/rebuild.m: Replace cellfun with strcat call.
* scripts/plot/axis.m: Use comma-separated lists to replace cellfun.
* scripts/plot/pareto.m: Use cellstr on char array to replace cellfun.
* scripts/plot/private/__gnuplot_print__.m: Use @times, rather than
anonymous function, in cellfun call.
* scripts/plot/private/__line__.m: White space cleanup.
* scripts/plot/private/__patch__.m: Use ismember to replace cellfun/strcmpi
combo. Use in-place '|=' operator for performance.
* scripts/plot/struct2hdl.m: Use ismember to replace cellfun/strcmp combo.
* scripts/polynomial/splinefit.m: Use built-in "isclass" rather than ischar.
* scripts/special-matrix/gallery.m: Remove anonymous functions inside cellfuns.
* scripts/strings/strsplit.m: Correct comment character to '#' from '%'.
* scripts/strings/untabify.m: Use multiple argument form of cellfun to get
rid of anonymous function.
* scripts/testfun/__run_test_suite__.m: Remove anonymous function from within
cellfun.
* scripts/ui/inputdlg.m: Use built-in "isclass" rather than ischar.
author | Rik <rik@octave.org> |
---|---|
date | Fri, 06 Sep 2013 14:08:42 -0700 |
parents | 1c89599167a6 |
children | d63878346099 |
comparison
equal
deleted
inserted
replaced
17385:5ca5aff90ffd | 17386:6dbc866379e2 |
---|---|
40 | 40 |
41 ## Generate cache | 41 ## Generate cache |
42 if (isempty (directory)) | 42 if (isempty (directory)) |
43 cache = gen_builtin_cache (); | 43 cache = gen_builtin_cache (); |
44 elseif (iscell (directory)) | 44 elseif (iscell (directory)) |
45 if (all (cellfun (@ischar, directory))) | 45 if (all (cellfun ("isclass", directory, "char"))) |
46 cache = gen_doc_cache_in_dir (directory); | 46 cache = gen_doc_cache_in_dir (directory); |
47 else | 47 else |
48 error ("doc_cache_create: cell must contain only strings"); | 48 error ("doc_cache_create: cell must contain only strings"); |
49 endif | 49 endif |
50 elseif (ischar (directory)) | 50 elseif (ischar (directory)) |
93 function cache = create_cache (list) | 93 function cache = create_cache (list) |
94 cache = {}; | 94 cache = {}; |
95 | 95 |
96 ## For each function: | 96 ## For each function: |
97 for n = 1:length (list) | 97 for n = 1:length (list) |
98 f = list {n}; | 98 f = list{n}; |
99 | 99 |
100 ## Get help text | 100 ## Get help text |
101 [text, format] = get_help_text (f); | 101 [text, format] = get_help_text (f); |
102 | 102 |
103 [text, first_sentence, status] = handle_function (f, text, format); | 103 [text, first_sentence, status] = handle_function (f, text, format); |
106 if (status != 0) | 106 if (status != 0) |
107 continue; | 107 continue; |
108 endif | 108 endif |
109 | 109 |
110 ## Store the help text | 110 ## Store the help text |
111 cache (1, end+1) = f; | 111 cache(1, end+1) = f; |
112 cache (2, end) = text; | 112 cache(2, end) = text; |
113 cache (3, end) = first_sentence; | 113 cache(3, end) = first_sentence; |
114 endfor | 114 endfor |
115 endfunction | 115 endfunction |
116 | 116 |
117 function cache = gen_doc_cache_in_dir (directory) | 117 function cache = gen_doc_cache_in_dir (directory) |
118 | 118 |
125 endif | 125 endif |
126 dirs_notpath = {directory{!dir_in_path}}; | 126 dirs_notpath = {directory{!dir_in_path}}; |
127 | 127 |
128 ## add them | 128 ## add them |
129 if (! isempty (dirs_notpath)) | 129 if (! isempty (dirs_notpath)) |
130 cellfun (@addpath, dirs_notpath); | 130 addpath (dirs_notpath{:}); |
131 endif | 131 endif |
132 | 132 |
133 ## create cache | 133 ## create cache |
134 func = @(s_) create_cache (__list_functions__ (s_)); | 134 func = @(s_) create_cache (__list_functions__ (s_)); |
135 cache = cellfun (func, directory, 'UniformOutput', false); | 135 cache = cellfun (func, directory, "UniformOutput", false); |
136 | 136 |
137 ## concatenate results | 137 ## concatenate results |
138 cache = [cache{:}]; | 138 cache = [cache{:}]; |
139 | 139 |
140 ## remove dirs form path | 140 ## remove dirs form path |
141 if (! isempty (dirs_notpath)) | 141 if (! isempty (dirs_notpath)) |
142 cellfun (@rmpath, dirs_notpath); | 142 rmpath (dirs_notpath{:}); |
143 endif | 143 endif |
144 | 144 |
145 endfunction | 145 endfunction |
146 | 146 |
147 function cache = gen_builtin_cache () | 147 function cache = gen_builtin_cache () |