Skip to content

Commit 4831572

Browse files
ezgicicekfacebook-github-bot
authored andcommitted
[website] Improve doc for INEFFICIENT_KEYSET_ITERATOR
Reviewed By: dulmarod Differential Revision: D32676900 fbshipit-source-id: 3d7caef6c2
1 parent 8c6bd5a commit 4831572

File tree

2 files changed

+10
-6
lines changed

2 files changed

+10
-6
lines changed

infer/documentation/issues/INEFFICIENT_KEYSET_ITERATOR.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,7 @@ This issue is raised when
22
- iterating over a HashMap with `ketSet()` iterator
33
- looking up the key each time
44

5-
Instead, it is more efficient to iterate over the loop with `entrySet` which returns key-vaue pairs and gets rid of the hashMap lookup.
6-
For instance, we would raise an issue for the following program:
5+
Example:
76

87
```java
98
void inefficient_loop_bad(HashMap<String, Integer> testMap) {
@@ -14,7 +13,10 @@ void inefficient_loop_bad(HashMap<String, Integer> testMap) {
1413
}
1514
```
1615

17-
Instead, it is more efficient to have:
16+
**Action**:
17+
18+
Instead, it is more efficient to iterate over the loop with `entrySet` which returns key-vaue pairs and gets rid of the hashMap lookup.
19+
1820
```java
1921
void efficient_loop_ok(HashMap<String, Integer> testMap) {
2022
for (Map.Entry<String, Integer> entry : testMap.entrySet()) {

website/docs/all-issue-types.md

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1187,8 +1187,7 @@ This issue is raised when
11871187
- iterating over a HashMap with `ketSet()` iterator
11881188
- looking up the key each time
11891189

1190-
Instead, it is more efficient to iterate over the loop with `entrySet` which returns key-vaue pairs and gets rid of the hashMap lookup.
1191-
For instance, we would raise an issue for the following program:
1190+
Example:
11921191

11931192
```java
11941193
void inefficient_loop_bad(HashMap<String, Integer> testMap) {
@@ -1199,7 +1198,10 @@ void inefficient_loop_bad(HashMap<String, Integer> testMap) {
11991198
}
12001199
```
12011200

1202-
Instead, it is more efficient to have:
1201+
**Action**:
1202+
1203+
Instead, it is more efficient to iterate over the loop with `entrySet` which returns key-vaue pairs and gets rid of the hashMap lookup.
1204+
12031205
```java
12041206
void efficient_loop_ok(HashMap<String, Integer> testMap) {
12051207
for (Map.Entry<String, Integer> entry : testMap.entrySet()) {

0 commit comments

Comments
 (0)