[cost] Add models: NSURL.getResourceValue, path

Reviewed By: ezgicicek

Differential Revision: D24417544

fbshipit-source-id: 96249dd14
master
Sungkeun Cho 4 years ago committed by Facebook GitHub Bot
parent 0f22f1bd95
commit b3c74c4152

@ -1169,6 +1169,12 @@ module NSCollection = struct
{exec; check= no_check}
end
module NSURL = struct
let get_resource_value =
let exec _model_env ~ret:(id, _) mem = model_by_value (Dom.Val.of_itv Itv.zero_one) id mem in
{exec; check= no_check}
end
module JavaClass = struct
let decl_array {pname; node_hash; location} ~ret:(ret_id, _) length mem =
let loc =
@ -1758,6 +1764,9 @@ module Call = struct
; +PatternMatch.ObjectiveC.implements "NSString"
&:: "initWithBytes:length:encoding:" <>$ capt_exp $+ capt_exp $+ capt_exp $+ any_arg
$!--> NSString.init_with_c_string_with_len
; +PatternMatch.ObjectiveC.implements "NSURL"
&:: "getResourceValue:forKey:error:" &--> NSURL.get_resource_value
; +PatternMatch.ObjectiveC.implements "NSURL" &:: "path" $ capt_exp $--> id
; (* C++ models *)
-"boost" &:: "split"
$ capt_arg_of_typ (-"std" &:: "vector")

@ -0,0 +1,19 @@
/*
* Copyright (c) Facebook, Inc. and its affiliates.
*
* This source code is licensed under the MIT license found in the
* LICENSE file in the root directory of this source tree.
*/
#import <Foundation/Foundation.h>
void get_resource_value_constant(NSURL* url) {
BOOL b = [url getResourceValue:nil forKey:@"key" error:nil];
for (int i = 0; i < b; i++) {
}
}
void path_linear(NSURL* url) {
NSString* path = (NSString*)url.path;
for (int i = 0; i < path.length; i++) {
}
}

@ -91,6 +91,8 @@ codetoanalyze/objc/performance/NSString.m, string_is_equal_to_string_linear, 4 +
codetoanalyze/objc/performance/NSString.m, string_length_linear, 3 + 3 ⋅ s.length.ub + 4 ⋅ (s.length.ub + 1), OnUIThread:false, [{s.length.ub + 1},Loop,{s.length.ub},Loop]
codetoanalyze/objc/performance/NSString.m, string_with_utf8_string_linear, 7 + 3 ⋅ p->strlen.ub + p->strlen.ub + 4 ⋅ (p->strlen.ub + 1), OnUIThread:false, [{p->strlen.ub + 1},Loop,{p->strlen.ub},Modeled call to NSString.stringWithUTF8String:,{p->strlen.ub},Loop]
codetoanalyze/objc/performance/NSString.m, substring_no_end_linear, 10 + 6 ⋅ (-x + s.length.ub), OnUIThread:false, [{-x + s.length.ub},Loop]
codetoanalyze/objc/performance/NSURL.m, get_resource_value_constant, 16, OnUIThread:false, []
codetoanalyze/objc/performance/NSURL.m, path_linear, 6 + 3 ⋅ url.length.ub + 3 ⋅ (url.length.ub + 1), OnUIThread:false, [{url.length.ub + 1},Loop,{url.length.ub},Loop]
codetoanalyze/objc/performance/araii.m, Araii.buffer, 4, OnUIThread:false, []
codetoanalyze/objc/performance/araii.m, Araii.dealloc, 4, OnUIThread:false, []
codetoanalyze/objc/performance/araii.m, Araii.initWithBuffer, 15, OnUIThread:false, []

Loading…
Cancel
Save