1
0
Fork 0
mirror of https://github.com/transmission/transmission synced 2024-12-25 17:17:31 +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]];
}
#warning use localizedStringWithFormat: directly in roardacted
+ (NSString *) formattedUInteger: (NSUInteger) value
{
NSNumberFormatter * numberFormatter = [[[NSNumberFormatter alloc] init] autorelease];
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
[numberFormatter setMaximumFractionDigits: 0];
static NSNumberFormatter * numberFormatter;
static dispatch_once_t onceToken;
dispatch_once(&onceToken, ^{
numberFormatter = [[NSNumberFormatter alloc] init];
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
[numberFormatter setMaximumFractionDigits: 0];
});
return [numberFormatter stringFromNumber: [NSNumber numberWithUnsignedInteger: value]];
}