[cost] add iterator support for nsdictionary

Summary: As title.

Reviewed By: ezgicicek

Differential Revision: D23371818

fbshipit-source-id: d894c956f
master
Qianyi Shu 4 years ago committed by Facebook GitHub Bot
parent 8447aa3fac
commit b71521a90a

@ -1703,6 +1703,10 @@ module Call = struct
&:: "allKeys" <>$ capt_exp $--> create_copy_array &:: "allKeys" <>$ capt_exp $--> create_copy_array
; +PatternMatch.ObjectiveC.implements "NSDictionary" ; +PatternMatch.ObjectiveC.implements "NSDictionary"
&:: "allValues" <>$ capt_exp $--> create_copy_array &:: "allValues" <>$ capt_exp $--> create_copy_array
; +PatternMatch.ObjectiveC.implements "NSDictionary"
&:: "objectEnumerator" <>$ capt_exp $--> NSCollection.iterator
; +PatternMatch.ObjectiveC.implements "NSDictionary"
&:: "keyEnumerator" <>$ capt_exp $--> NSCollection.iterator
; +PatternMatch.ObjectiveC.implements "NSNumber" &:: "numberWithInt:" <>$ capt_exp $--> id ; +PatternMatch.ObjectiveC.implements "NSNumber" &:: "numberWithInt:" <>$ capt_exp $--> id
; +PatternMatch.ObjectiveC.implements "NSNumber" &:: "integerValue" <>$ capt_exp $--> id ; +PatternMatch.ObjectiveC.implements "NSNumber" &:: "integerValue" <>$ capt_exp $--> id
; +PatternMatch.ObjectiveC.implements "NSString" ; +PatternMatch.ObjectiveC.implements "NSString"

@ -67,7 +67,7 @@ void nsdictionary_all_values_linear(NSDictionary* dict) {
} }
} }
id nsdictionary_find_key_linear_FN(NSDictionary* dict, id item) { id nsdictionary_find_key_constant(NSDictionary* dict, id item) {
NSEnumerator* enumerator = [dict keyEnumerator]; NSEnumerator* enumerator = [dict keyEnumerator];
id key; id key;
while ((key = [enumerator nextObject]) && dict[key] == item) { while ((key = [enumerator nextObject]) && dict[key] == item) {
@ -78,7 +78,7 @@ id nsdictionary_find_key_linear_FN(NSDictionary* dict, id item) {
// enumerate dictionary // enumerate dictionary
void nsdictionary_fast_enumerate_linear_FN(NSDictionary* dict) { void nsdictionary_fast_enumerate_linear(NSDictionary* dict) {
for (id key in dict) { for (id key in dict) {
} }
} }
@ -93,7 +93,7 @@ void nsdictionary_enumerate_constant() {
} }
} }
void nsdictionary_enumerator_linear_FN(NSDictionary* dict) { void nsdictionary_enumerator_linear(NSDictionary* dict) {
NSEnumerator* enumerator = [dict keyEnumerator]; NSEnumerator* enumerator = [dict keyEnumerator];
id key; id key;
while ((key = [enumerator nextObject])) { while ((key = [enumerator nextObject])) {

@ -7,8 +7,7 @@
#import <Foundation/Foundation.h> #import <Foundation/Foundation.h>
// set element // set element
void nsmutabledictionary_set_element_in_loop_linear_FN( void nsmutabledictionary_set_element_in_loop_linear(NSMutableDictionary* dict) {
NSMutableDictionary* dict) {
for (NSString* key in dict) { for (NSString* key in dict) {
dict[key] = key; dict[key] = key;
} }

@ -30,9 +30,9 @@ codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_all_keys_linear2, 6
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_all_values_linear, 3 + 3 ⋅ dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_all_values_linear, 3 + 3 ⋅ dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_dictionary_with_objects_linear, 14 + 15 ⋅ n_entries + 3 ⋅ n_entries + 2 ⋅ (1+max(0, n_entries)) + 4 ⋅ (1+max(0, n_entries)), OnUIThread:false, [{1+max(0, n_entries)},Loop,{1+max(0, n_entries)},Loop,{n_entries},Loop,{n_entries},Loop] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_dictionary_with_objects_linear, 14 + 15 ⋅ n_entries + 3 ⋅ n_entries + 2 ⋅ (1+max(0, n_entries)) + 4 ⋅ (1+max(0, n_entries)), OnUIThread:false, [{1+max(0, n_entries)},Loop,{1+max(0, n_entries)},Loop,{n_entries},Loop,{n_entries},Loop]
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_enumerate_constant, 52, OnUIThread:false, [] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_enumerate_constant, 52, OnUIThread:false, []
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_enumerator_linear_FN, 10, OnUIThread:false, [] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_enumerator_linear, 5 + dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_fast_enumerate_linear_FN, 10, OnUIThread:false, [] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_fast_enumerate_linear, 5 + dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_find_key_linear_FN, 19, OnUIThread:false, [] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_find_key_constant, 19, OnUIThread:false, []
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_dictionary_constant, 3, OnUIThread:false, [] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_dictionary_constant, 3, OnUIThread:false, []
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_literal_constant, 41, OnUIThread:false, [] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_literal_constant, 41, OnUIThread:false, []
codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_with_dictionary_linear_FP, , OnUIThread:false, [Unbounded loop,Loop] codetoanalyze/objc/performance/NSDictionary.m, nsdictionary_init_with_dictionary_linear_FP, , OnUIThread:false, [Unbounded loop,Loop]
@ -51,7 +51,7 @@ codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_remove_constant, 17,
codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_remove_in_loop_constant, 182, OnUIThread:false, [] codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_remove_in_loop_constant, 182, OnUIThread:false, []
codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_set_in_loop_constant, 51, OnUIThread:false, [] codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_set_in_loop_constant, 51, OnUIThread:false, []
codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_set_linear, 3 + 11 ⋅ array->elements.length.ub + 3 ⋅ (array->elements.length.ub + 1), OnUIThread:false, [{array->elements.length.ub + 1},Loop,{array->elements.length.ub},Loop] codetoanalyze/objc/performance/NSMutableArray.m, nsmarray_set_linear, 3 + 11 ⋅ array->elements.length.ub + 3 ⋅ (array->elements.length.ub + 1), OnUIThread:false, [{array->elements.length.ub + 1},Loop,{array->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSMutableDictionary.m, nsmutabledictionary_set_element_in_loop_linear_FN, 14, OnUIThread:false, [] codetoanalyze/objc/performance/NSMutableDictionary.m, nsmutabledictionary_set_element_in_loop_linear, 5 + 5 ⋅ dict->elements.length.ub + 4 ⋅ (dict->elements.length.ub + 1), OnUIThread:false, [{dict->elements.length.ub + 1},Loop,{dict->elements.length.ub},Loop]
codetoanalyze/objc/performance/NSMutableString.m, nsmstring_append_string_constant, 14 + 3 ⋅ (str.length.ub + 5) + 3 ⋅ (str.length.ub + 6), OnUIThread:false, [{str.length.ub + 6},Loop,{str.length.ub + 5},Loop] codetoanalyze/objc/performance/NSMutableString.m, nsmstring_append_string_constant, 14 + 3 ⋅ (str.length.ub + 5) + 3 ⋅ (str.length.ub + 6), OnUIThread:false, [{str.length.ub + 6},Loop,{str.length.ub + 5},Loop]
codetoanalyze/objc/performance/NSMutableString.m, nsmstring_append_string_linear, 5 + str2.length.ub + 3 ⋅ (str2.length.ub + str1.length.ub) + 3 ⋅ (str2.length.ub + str1.length.ub + 1), OnUIThread:false, [{str2.length.ub + str1.length.ub + 1},Loop,{str2.length.ub + str1.length.ub},Loop,{str2.length.ub},Modeled call to NSMutableString.appendString:] codetoanalyze/objc/performance/NSMutableString.m, nsmstring_append_string_linear, 5 + str2.length.ub + 3 ⋅ (str2.length.ub + str1.length.ub) + 3 ⋅ (str2.length.ub + str1.length.ub + 1), OnUIThread:false, [{str2.length.ub + str1.length.ub + 1},Loop,{str2.length.ub + str1.length.ub},Loop,{str2.length.ub},Modeled call to NSMutableString.appendString:]
codetoanalyze/objc/performance/NSString.m, call_component_separated_by_char_constant, 46, OnUIThread:false, [] codetoanalyze/objc/performance/NSString.m, call_component_separated_by_char_constant, 46, OnUIThread:false, []

Loading…
Cancel
Save