Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
16 changes: 6 additions & 10 deletions Sources/Core/GTLRBase64.m
Original file line number Diff line number Diff line change
Expand Up @@ -119,24 +119,20 @@ static void CreateDecodingTable(const char *encodingTable,

NSData *GTLRDecodeBase64(NSString *base64Str) {
static char decodingTable[128];
static BOOL hasInited = NO;

if (!hasInited) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
CreateDecodingTable(gStandardEncodingTable, sizeof(gStandardEncodingTable),
decodingTable);
hasInited = YES;
}
});
return DecodeBase64StringCommon(base64Str, decodingTable, YES /* requirePadding */ );
}

NSData *GTLRDecodeWebSafeBase64(NSString *base64Str) {
static char decodingTable[128];
static BOOL hasInited = NO;

if (!hasInited) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
CreateDecodingTable(gWebSafeEncodingTable, sizeof(gWebSafeEncodingTable),
decodingTable);
hasInited = YES;
}
});
return DecodeBase64StringCommon(base64Str, decodingTable, NO /* requirePadding */);
}
7 changes: 3 additions & 4 deletions Sources/Core/GTLRRuntimeCommon.m
Original file line number Diff line number Diff line change
Expand Up @@ -484,19 +484,18 @@ typedef NS_ENUM(NSUInteger, GTLRPropertyType) {
},
};

static BOOL hasLookedUpClasses = NO;
if (!hasLookedUpClasses) {
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
// Unfortunately, you can't put [NSString class] into the static structure,
Comment thread
thomasvl marked this conversation as resolved.
// so this lookup has to be done at runtime.
hasLookedUpClasses = YES;
for (uint32_t idx = 0; idx < sizeof(kImplInfo)/sizeof(kImplInfo[0]); ++idx) {
if (kImplInfo[idx].returnClassName) {
kImplInfo[idx].returnClass = objc_getClass(kImplInfo[idx].returnClassName);
NSCAssert1(kImplInfo[idx].returnClass != nil,
@"GTLRRuntimeCommon: class lookup failed: %s", kImplInfo[idx].returnClassName);
}
}
}
});

const char *attr = property_getAttributes(prop);

Expand Down
15 changes: 7 additions & 8 deletions Sources/Core/GTLRUtilities.m
Original file line number Diff line number Diff line change
Expand Up @@ -85,14 +85,13 @@ BOOL GTLR_AreBoolsEqual(BOOL b1, BOOL b2) {
if ([str rangeOfString:@"."].location != NSNotFound) {
// This is a floating-point number.
// Force the parser to use '.' as the decimal separator.
static NSLocale *usLocale = nil;
@synchronized([GTLRUtilities class]) {
if (usLocale == nil) {
usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
}
newNum = [NSDecimalNumber decimalNumberWithString:(NSString*)num
locale:(id)usLocale];
}
static NSLocale *usLocale;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
usLocale = [[NSLocale alloc] initWithLocaleIdentifier:@"en_US"];
Comment thread
thomasvl marked this conversation as resolved.
});
newNum = [NSDecimalNumber decimalNumberWithString:(NSString*)num
locale:(id)usLocale];
} else {
// NSDecimalNumber +decimalNumberWithString:locale:
// does not correctly create an NSNumber for large values like
Expand Down
Loading