aboutsummaryrefslogtreecommitdiffstats
path: root/lib/stdlib/src/erl_anno.erl
diff options
context:
space:
mode:
authorJosé Valim <[email protected]>2015-05-14 18:51:11 +0200
committerJosé Valim <[email protected]>2015-05-14 18:56:31 +0200
commit7168dabcc8127726ab32518e190bee8e7cd9795c (patch)
tree8f79d09ba43078903824ae80d98ce1dbb205c416 /lib/stdlib/src/erl_anno.erl
parent9a81b28598fadc44bf506354c9227e41aac786f6 (diff)
downloadotp-7168dabcc8127726ab32518e190bee8e7cd9795c.tar.gz
otp-7168dabcc8127726ab32518e190bee8e7cd9795c.tar.bz2
otp-7168dabcc8127726ab32518e190bee8e7cd9795c.zip
Speed up linting by not traversing filenames in erl_anno
Compilation on Erlang 18.0-rc2 is about 10% slower than in Erlang 17. After some debugging, we have noticed that linting is on average 30% to 50% slower being the main responsible for the performance reduction. Later profiling revealed is_filename/1 to be the biggest culprit. The change in this commit brings compilation times to about the same times as Erlang 17. Note this commit doesn't change the compiler behaviour compared to Erlang 17 because we didn't sanity check the value given to the file annotation in the past. I would say checking the filename is not worth it if it means compilation becomes 10% slower on average. After all, there are many places in the compiler where it will fail if we give it a malformed tree, I wouldn't then special case file annotation.
Diffstat (limited to 'lib/stdlib/src/erl_anno.erl')
-rw-r--r--lib/stdlib/src/erl_anno.erl2
1 files changed, 1 insertions, 1 deletions
diff --git a/lib/stdlib/src/erl_anno.erl b/lib/stdlib/src/erl_anno.erl
index 963b7278a6..9fb767fc93 100644
--- a/lib/stdlib/src/erl_anno.erl
+++ b/lib/stdlib/src/erl_anno.erl
@@ -147,7 +147,7 @@ is_anno2(_, _) ->
false.
is_filename(T) ->
- is_string(T) orelse is_binary(T).
+ is_list(T) orelse is_binary(T).
is_string(T) ->
try lists:all(fun(C) when is_integer(C), C >= 0 -> true end, T)