mirror of
https://github.com/transmission/transmission
synced 2024-12-26 17:47:37 +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]];
|
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;
|
||||||
|
static dispatch_once_t onceToken;
|
||||||
|
dispatch_once(&onceToken, ^{
|
||||||
|
numberFormatter = [[NSNumberFormatter alloc] init];
|
||||||
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
|
[numberFormatter setNumberStyle: NSNumberFormatterDecimalStyle];
|
||||||
[numberFormatter setMaximumFractionDigits: 0];
|
[numberFormatter setMaximumFractionDigits: 0];
|
||||||
|
});
|
||||||
|
|
||||||
return [numberFormatter stringFromNumber: [NSNumber numberWithUnsignedInteger: value]];
|
return [numberFormatter stringFromNumber: [NSNumber numberWithUnsignedInteger: value]];
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue