From 7168dabcc8127726ab32518e190bee8e7cd9795c Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Jos=C3=A9=20Valim?= Date: Thu, 14 May 2015 18:51:11 +0200 Subject: 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. --- lib/stdlib/src/erl_anno.erl | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'lib') 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) -- cgit v1.2.3