makeValidName>getMakeValidFcnHandle/makeValid (Calls: 1, Time: 0.002 s)
Generated 18-May-2021 16:05:21 using performance time.
nested function in file /usr/local/MATLAB/R2021a/toolbox/matlab/lang/+matlab/+lang/makeValidName.m
Copy to new window for comparing multiple runs
| Function Name | Function Type | Calls |
| ...n)makeValid(n,@replaceWithUnderscore) | anonymous function | 1 |
| Line Number | Code | Calls | Total Time | % Time | Time Plot |
| 162 | if iskeyword(name(keywordIdx)) | 63 | 0.001 s | 57.4% | |
| 158 | name = invalidReplacementFun(n... | 1 | 0.000 s | 14.8% | |
| 169 | name = regexprep(name,'^(?![a-... | 1 | 0.000 s | 6.0% | |
| 161 | for keywordIdx = 1:numel(name) | 1 | 0.000 s | 5.9% | |
| 172 | isTooLong = (strlength(name) &... | 1 | 0.000 s | 5.3% | |
| All other lines | 0.000 s | 10.7% | |||
| Totals | 0.002 s | 100% |
| Function Name | Function Type | Calls | Total Time | % Time | Time Plot |
| iskeyword | function | 63 | 0.001 s | 31.0% | |
| ...eValidFcnHandle/replaceWithUnderscore | nested function | 1 | 0.000 s | 11.5% | |
| Self time (built-ins, overhead, etc.) | 0.001 s | 57.5% | |||
| Totals | 0.002 s | 100% |
| Total lines in function | 31 |
| Non-code lines (comments, blank lines) | 11 |
| Code lines (lines that can run) | 20 |
| Code lines that did run | 13 |
| Code lines that did not run | 7 |
| Coverage (did run/can run) | 65.00 % |
time | Calls | line | |
|---|---|---|---|
148 | function name = makeValid(name, invalidReplacementFun) | ||
149 | % Remove leading and trailing whitespace and | ||
150 | % replace embedded whitespace with camel/mixed casing. | ||
< 0.001 | 1 | 151 | whitespace = compose([" ", "\f", "\n", "\r", "\t", "\v"]); |
< 0.001 | 1 | 152 | if any(contains(name, whitespace)) |
153 | name = regexprep(name, '(?<=\S)\s+([a-z])', '${upper($1)}'); | ||
154 | name = erase(name, whitespace); | ||
< 0.001 | 1 | 155 | end |
156 | |||
157 | % Replace invalid characters as specified by ReplacementStyle. | ||
< 0.001 | 1 | 158 | name = invalidReplacementFun(name); |
159 | |||
160 | % Prepend keyword with PREFIX and camel case. | ||
< 0.001 | 1 | 161 | for keywordIdx = 1:numel(name) |
0.001 | 63 | 162 | if iskeyword(name(keywordIdx)) |
163 | name{keywordIdx} = [prefix, upper(name{keywordIdx}(1)), ... | ||
164 | lower(name{keywordIdx}(2:end))]; | ||
< 0.001 | 63 | 165 | end |
< 0.001 | 63 | 166 | end |
167 | |||
168 | % Insert PREFIX if the first column is non-letter. | ||
< 0.001 | 1 | 169 | name = regexprep(name,'^(?![a-z])', prefix, 'emptymatch', 'ignorecase'); |
170 | |||
171 | % Truncate NAME to NAMLENGTHMAX. | ||
< 0.001 | 1 | 172 | isTooLong = (strlength(name) > namelengthmax); |
< 0.001 | 1 | 173 | if any(isTooLong) |
174 | for isTooLongIdx = reshape(find(isTooLong), 1, []) | ||
175 | name{isTooLongIdx} = name{isTooLongIdx}(1:namelengthmax); | ||
176 | end | ||
< 0.001 | 1 | 177 | end |
< 0.001 | 1 | 178 | end |
Other subfunctions in this file are not included in this listing.