Mercurial > octave
changeset 27333:2c4759c8239c
dir.m: Tweak code for 10% performance improvement.
* dir.m: Replace regexp call with regexprep and strcmp test.
author | Rik <rik@octave.org> |
---|---|
date | Wed, 07 Aug 2019 12:57:25 -0700 |
parents | c80ba7295b5e |
children | 50216d7a2f6b |
files | scripts/miscellaneous/dir.m |
diffstat | 1 files changed, 3 insertions(+), 4 deletions(-) [+] |
line wrap: on
line diff
--- a/scripts/miscellaneous/dir.m Wed Aug 07 12:21:47 2019 -0700 +++ b/scripts/miscellaneous/dir.m Wed Aug 07 12:57:25 2019 -0700 @@ -136,11 +136,10 @@ st = xst; endif endif - [sts, tmpdir] = regexp (fn, re, "start", "tokens"); - if (isempty (sts)) + tmpdir = regexprep (fn, re, '$1'); + if (strcmp (fn, tmpdir)) + ## regexrep failed to match, no directory component. tmpdir = "."; - else - tmpdir = tmpdir{1}{1}; endif fn = regexprep (fn, re, '$2$3'); info(++cnt).name = fn;