-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
1 parent
fcd5590
commit f5b613e
Showing
158 changed files
with
388 additions
and
328 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,32 @@ | ||
--- | ||
sidebar_position: 36 | ||
--- | ||
|
||
# W0036 - unnecessary Map From List Around Comprehension | ||
|
||
## Warning | ||
|
||
```erlang | ||
fn(List) -> maps:from_list([{K + 1, V + 2} || {K,V} <- List]). | ||
%% ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 💡 weak: Unnecessary intermediate list allocated. | ||
``` | ||
|
||
## Explanation | ||
|
||
The warning message indicates an unidiomatic and sub-optimal way to build a map | ||
from a list. | ||
|
||
Whilst the comprehension and subsequent call to `maps:from_list/1` will ultimately | ||
construct a map from the key-values pair in the given list, it is less | ||
efficient than it could be, since an intermediate list is created by the list | ||
comprehension. | ||
|
||
Using the map comprehension syntax is clearer and more performant. | ||
|
||
To fix this warning, replace the list comprehension and `maps:from_list/1` call | ||
with a map comprehension: | ||
|
||
```erlang | ||
main(List) -> | ||
#{K + 1 => V + 2 || {K,V} <- List}. | ||
``` |
This file was deleted.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
2 changes: 1 addition & 1 deletion
2
assets/js/27b30b7f.dd06a4f0.js → assets/js/27b30b7f.6c53f296.js
Large diffs are not rendered by default.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Large diffs are not rendered by default.
Oops, something went wrong.
File renamed without changes.
This file was deleted.
Oops, something went wrong.
Oops, something went wrong.