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:
Tadeu Zagallo
2015-11-08 10:19:26 -08:00
committed by facebook-github-bot-6
parent 1f0d48a0e4
commit e1fa325569
3 changed files with 11 additions and 11 deletions

View File

@@ -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);

View File

@@ -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);

View File

@@ -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;
}