[inferbo] Add models for Java Collections

Summary:
Add models for
- `singletonMap`
- `singletonList`
- `emptyList`
- `emptyMap`

Reviewed By: skcho

Differential Revision: D19087648

fbshipit-source-id: 059e36383
master
Ezgi Çiçek 6 years ago committed by Facebook Github Bot
parent 9285c51dfa
commit 12478e1238

@ -1312,7 +1312,13 @@ module Call = struct
(* model sets as lists *)
; +PatternMatch.implements_collections &::+ unmodifiable <>$ capt_exp $--> Collection.iterator
; +PatternMatch.implements_collections &:: "singleton" <>--> Collection.singleton_collection
; +PatternMatch.implements_collections
&:: "singletonList" <>--> Collection.singleton_collection
; +PatternMatch.implements_collections
&:: "singletonMap" <>--> Collection.singleton_collection
; +PatternMatch.implements_collections &:: "emptyList" <>--> Collection.new_collection
; +PatternMatch.implements_collections &:: "emptySet" <>--> Collection.new_collection
; +PatternMatch.implements_collections &:: "emptyMap" <>--> Collection.new_collection
(* model maps as lists *)
; +PatternMatch.implements_collections
&:: "singletonMap" <>--> Collection.singleton_collection

@ -65,4 +65,12 @@ class CollectionsTest {
Set<String> set = Collections.emptySet();
for (String s : set) {}
}
void emptyList_constant() {
for (int i = 0; i < Collections.emptyList().size(); i++) {}
}
void singletonMap_constant() {
for (int i = 0; i < Collections.singletonMap(1, 1).size(); i++) {}
}
}

@ -73,6 +73,7 @@ codetoanalyze/java/performance/CollectionTest.java, CollectionTest.nested_iterat
codetoanalyze/java/performance/CollectionTest.java, CollectionTest.sparse_array_linear(android.util.SparseArray):void, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 2 + 5 ⋅ arr.length + 3 ⋅ (arr.length + 1), O(arr.length), degree = 1,{arr.length + 1},Loop at line 64,{arr.length},Loop at line 64]
codetoanalyze/java/performance/CollectionsTest.java, CollectionsTest.binary_search_log(java.util.List):int, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 2 + log(list.length), O(log(list.length)), degree = 0 + 1⋅log,{list.length},Modeled call to Collections.binarySearch]
codetoanalyze/java/performance/CollectionsTest.java, CollectionsTest.copy_linear(java.util.List,java.util.List):void, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 3 + list_to.length, O(list_to.length), degree = 1,{list_to.length},Modeled call to Collections.copy]
codetoanalyze/java/performance/CollectionsTest.java, CollectionsTest.emptyList_constant():void, 1, CONDITION_ALWAYS_FALSE, no_bucket, WARNING, [Here]
codetoanalyze/java/performance/CollectionsTest.java, CollectionsTest.emptySet_zero():void, 2, CONDITION_ALWAYS_FALSE, no_bucket, WARNING, [Here]
codetoanalyze/java/performance/CollectionsTest.java, CollectionsTest.fill_linear(java.util.List,java.lang.String):void, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 3 + list.length, O(list.length), degree = 1,{list.length},Modeled call to Collections.fill]
codetoanalyze/java/performance/CollectionsTest.java, CollectionsTest.reverse_linear(java.util.List):void, 1, EXPENSIVE_EXECUTION_TIME, no_bucket, ERROR, [with estimated cost 2 + list.length, O(list.length), degree = 1,{list.length},Modeled call to Collections.reverse]

Loading…
Cancel
Save