diff options
author | Björn Gustavsson <[email protected]> | 2011-09-04 09:20:11 +0200 |
---|---|---|
committer | Björn Gustavsson <[email protected]> | 2011-10-09 11:33:21 +0200 |
commit | 44d3cf7625aa869829c59567d8fc6403eb0a1518 (patch) | |
tree | 862d89e90d5dcaeffcedf4b7618b2625689c6eae /lib/stdlib/src/filename.erl | |
parent | 8f4523c56f243aa4fc4ff4415f89dd1924e49d62 (diff) | |
download | otp-44d3cf7625aa869829c59567d8fc6403eb0a1518.tar.gz otp-44d3cf7625aa869829c59567d8fc6403eb0a1518.tar.bz2 otp-44d3cf7625aa869829c59567d8fc6403eb0a1518.zip |
Optimize filename:extension/1 to produce less garbage
Simply return a tail of the flattened filename.
Diffstat (limited to 'lib/stdlib/src/filename.erl')
-rw-r--r-- | lib/stdlib/src/filename.erl | 8 |
1 files changed, 4 insertions, 4 deletions
diff --git a/lib/stdlib/src/filename.erl b/lib/stdlib/src/filename.erl index 1cb9e4a25e..b9665d7dec 100644 --- a/lib/stdlib/src/filename.erl +++ b/lib/stdlib/src/filename.erl @@ -369,8 +369,8 @@ extension(Name0) -> Name = flatten(Name0), extension(Name, [], major_os_type()). -extension([$.|Rest], _Result, OsType) -> - extension(Rest, [$.], OsType); +extension([$.|Rest]=Result, _Result, OsType) -> + extension(Rest, Result, OsType); extension([Char|Rest], [], OsType) when is_integer(Char) -> extension(Rest, [], OsType); extension([$/|Rest], _Result, OsType) -> @@ -378,9 +378,9 @@ extension([$/|Rest], _Result, OsType) -> extension([$\\|Rest], _Result, win32) -> extension(Rest, [], win32); extension([Char|Rest], Result, OsType) when is_integer(Char) -> - extension(Rest, [Char|Result], OsType); + extension(Rest, Result, OsType); extension([], Result, _OsType) -> - lists:reverse(Result). + Result. %% Joins a list of filenames with directory separators. |