mirror of
https://github.com/zhigang1992/react-native.git
synced 2026-05-06 17:52:57 +08:00
Change async events' cookie to NSUInteger
Summary: public As jspahrsumemrs pointed out, `int` could overflow pretty easy, since it was static, change it to an NSUInteger and downcast it when need to interop. Reviewed By: jspahrsummers Differential Revision: D2625902 fb-gh-sync-id: 2052be47a7b0ed81484da004fa18d6ef5baf26f7
This commit is contained in:
committed by
facebook-github-bot-6
parent
1f0d48a0e4
commit
e1fa325569
@@ -175,7 +175,7 @@ RCT_EXTERN NSArray<Class> *RCTGetModuleClasses(void);
|
||||
- (void)loadSource:(RCTSourceLoadBlock)_onSourceLoad
|
||||
{
|
||||
RCTPerformanceLoggerStart(RCTPLScriptDownload);
|
||||
int cookie = RCTProfileBeginAsyncEvent(0, @"JavaScript download", nil);
|
||||
NSUInteger cookie = RCTProfileBeginAsyncEvent(0, @"JavaScript download", nil);
|
||||
|
||||
RCTSourceLoadBlock onSourceLoad = ^(NSError *error, NSData *source) {
|
||||
RCTProfileEndAsyncEvent(0, @"init,download", cookie, @"JavaScript download", nil);
|
||||
|
||||
@@ -98,9 +98,9 @@ RCT_EXTERN void _RCTProfileEndEvent(NSThread *calleeThread,
|
||||
/**
|
||||
* Collects the initial event information for the event and returns a reference ID
|
||||
*/
|
||||
RCT_EXTERN int RCTProfileBeginAsyncEvent(uint64_t tag,
|
||||
NSString *name,
|
||||
NSDictionary *args);
|
||||
RCT_EXTERN NSUInteger RCTProfileBeginAsyncEvent(uint64_t tag,
|
||||
NSString *name,
|
||||
NSDictionary *args);
|
||||
|
||||
/**
|
||||
* The ID returned by BeginEvent should then be passed into EndEvent, with the
|
||||
@@ -109,7 +109,7 @@ RCT_EXTERN int RCTProfileBeginAsyncEvent(uint64_t tag,
|
||||
*/
|
||||
RCT_EXTERN void RCTProfileEndAsyncEvent(uint64_t tag,
|
||||
NSString *category,
|
||||
int cookie,
|
||||
NSUInteger cookie,
|
||||
NSString *name,
|
||||
NSDictionary *args);
|
||||
|
||||
|
||||
@@ -420,20 +420,20 @@ void _RCTProfileEndEvent(
|
||||
);
|
||||
}
|
||||
|
||||
int RCTProfileBeginAsyncEvent(
|
||||
NSUInteger RCTProfileBeginAsyncEvent(
|
||||
uint64_t tag,
|
||||
NSString *name,
|
||||
NSDictionary *args
|
||||
) {
|
||||
CHECK(0);
|
||||
|
||||
static int eventID = 0;
|
||||
static NSUInteger eventID = 0;
|
||||
|
||||
NSTimeInterval time = CACurrentMediaTime();
|
||||
int currentEventID = ++eventID;
|
||||
NSUInteger currentEventID = ++eventID;
|
||||
|
||||
if (callbacks != NULL) {
|
||||
callbacks->begin_async_section(tag, name.UTF8String, eventID, args.count, RCTProfileSystraceArgsFromNSDictionary(args));
|
||||
callbacks->begin_async_section(tag, name.UTF8String, (int)(currentEventID % INT_MAX), args.count, RCTProfileSystraceArgsFromNSDictionary(args));
|
||||
} else {
|
||||
dispatch_async(RCTProfileGetQueue(), ^{
|
||||
RCTProfileOngoingEvents[@(currentEventID)] = @[
|
||||
@@ -450,14 +450,14 @@ int RCTProfileBeginAsyncEvent(
|
||||
void RCTProfileEndAsyncEvent(
|
||||
uint64_t tag,
|
||||
NSString *category,
|
||||
int cookie,
|
||||
NSUInteger cookie,
|
||||
NSString *name,
|
||||
NSDictionary *args
|
||||
) {
|
||||
CHECK();
|
||||
|
||||
if (callbacks != NULL) {
|
||||
callbacks->end_async_section(tag, name.UTF8String, cookie, args.count, RCTProfileSystraceArgsFromNSDictionary(args));
|
||||
callbacks->end_async_section(tag, name.UTF8String, (int)(cookie % INT_MAX), args.count, RCTProfileSystraceArgsFromNSDictionary(args));
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user