Commit 1d77d92
committed
refactor(linter): avoid unnecessary var initialization (#13072)
Further refactor of `process_path`, continuing from #13070.
Avoid unnecessary pre-initialization of `records` and `module_content`, when mostly they're overwritten later. Instead, each branch of the `if` / `else` hold their own vars, and construct a `ProcessedModule`.
There may be some tiny perf benefit of skipping the initializations, but mainly motivation is to make it more explicit what each branch returns, which personally I find makes the logic easier to follow.
Also de-duplicate creation of `allocator_guard`, which was previously repeated in both branches.1 parent 1c15288 commit 1d77d92
1 file changed
+9
-10
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
887 | 887 | | |
888 | 888 | | |
889 | 889 | | |
890 | | - | |
891 | | - | |
| 890 | + | |
892 | 891 | | |
893 | 892 | | |
894 | | - | |
| 893 | + | |
| 894 | + | |
895 | 895 | | |
896 | | - | |
| 896 | + | |
897 | 897 | | |
898 | 898 | | |
899 | 899 | | |
| |||
920 | 920 | | |
921 | 921 | | |
922 | 922 | | |
923 | | - | |
| 923 | + | |
924 | 924 | | |
925 | | - | |
| 925 | + | |
926 | 926 | | |
927 | | - | |
928 | 927 | | |
929 | 928 | | |
930 | 929 | | |
| |||
937 | 936 | | |
938 | 937 | | |
939 | 938 | | |
940 | | - | |
| 939 | + | |
941 | 940 | | |
942 | 941 | | |
943 | 942 | | |
| |||
946 | 945 | | |
947 | 946 | | |
948 | 947 | | |
949 | | - | |
950 | 948 | | |
951 | | - | |
| 949 | + | |
| 950 | + | |
952 | 951 | | |
953 | 952 | | |
954 | 953 | | |
| |||
0 commit comments