Replaced RCTSparseArray with NSDictionary

Reviewed By: jspahrsummers

Differential Revision: D2651920

fb-gh-sync-id: 953e2ea33abfc7a3a553da95b13e9ab2bccc5a1c
This commit is contained in:
Nick Lockwood
2015-11-14 10:25:00 -08:00
committed by facebook-github-bot-4
parent 5a34a097f2
commit fa0b45c58b
67 changed files with 338 additions and 547 deletions

View File

@@ -12,7 +12,6 @@
#import "RCTAssert.h"
#import "RCTBridge.h"
#import "RCTLog.h"
#import "RCTSparseArray.h"
#import "RCTUtils.h"
@interface RCTBridge (Private)
@@ -66,7 +65,7 @@
@implementation RCTTiming
{
RCTSparseArray *_timers;
NSMutableDictionary<NSNumber *, RCTTimer *> *_timers;
}
@synthesize bridge = _bridge;
@@ -79,7 +78,7 @@ RCT_EXPORT_MODULE()
{
if ((self = [super init])) {
_paused = YES;
_timers = [RCTSparseArray new];
_timers = [NSMutableDictionary new];
for (NSString *name in @[UIApplicationWillResignActiveNotification,
UIApplicationDidEnterBackgroundNotification,
@@ -146,12 +145,12 @@ RCT_EXPORT_MODULE()
- (void)didUpdateFrame:(__unused RCTFrameUpdate *)update
{
NSMutableArray<NSNumber *> *timersToCall = [NSMutableArray new];
for (RCTTimer *timer in _timers.allObjects) {
for (RCTTimer *timer in _timers.allValues) {
if ([timer updateFoundNeedsJSUpdate]) {
[timersToCall addObject:timer.callbackID];
}
if (!timer.target) {
_timers[timer.callbackID] = nil;
[_timers removeObjectForKey:timer.callbackID];
}
}
@@ -208,7 +207,7 @@ RCT_EXPORT_METHOD(createTimer:(nonnull NSNumber *)callbackID
RCT_EXPORT_METHOD(deleteTimer:(nonnull NSNumber *)timerID)
{
_timers[timerID] = nil;
[_timers removeObjectForKey:timerID];
if (_timers.count == 0) {
[self stopTimers];
}