1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-26 09:37:56 +00:00

only create the number formatter for formatting integers once

This commit is contained in:
Mitchell Livingston 2012-06-28 12:29:01 +00:00
parent e5d37376ff
commit bc3026a13f

View file

@ -48,11 +48,16 @@
return [self stringByAppendingString: [NSString ellipsis]]; return [self stringByAppendingString: [NSString ellipsis]];
} }
#warning use localizedStringWithFormat: directly in roardacted
+ (NSString *) formattedUInteger: (NSUInteger) value + (NSString *) formattedUInteger: (NSUInteger) value
{ {
NSNumberFormatter * numberFormatter = [[[NSNumberFormatter alloc] init] autorelease]; static NSNumberFormatter * numberFormatter;
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle]; static dispatch_once_t onceToken;
[numberFormatter setMaximumFractionDigits: 0]; dispatch_once(&onceToken, ^{
numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
[numberFormatter setMaximumFractionDigits: 0];
});
return [numberFormatter stringFromNumber: [NSNumber numberWithUnsignedInteger: value]]; return [numberFormatter stringFromNumber: [NSNumber numberWithUnsignedInteger: value]];
} }