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:
parent
e5d37376ff
commit
bc3026a13f
1 changed files with 8 additions and 3 deletions
|
@ -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]];
|
||||
}
|
||||
|
|
Loading…
Reference in a new issue