We read every piece of feedback, and take your input very seriously.
To see all available qualifiers, see our documentation.
There was an error while loading. Please reload this page.
1 parent 3a3da52 commit 688a00aCopy full SHA for 688a00a
Foundation/ByteCountFormatter.swift
@@ -353,15 +353,17 @@ open class ByteCountFormatter : Formatter {
353
354
// A helper method to return the length of an int
355
private func lengthOfInt(number: Int) -> Int {
356
+ guard number != 0 else {
357
+ return 1
358
+ }
359
var num = abs(number)
- var length: [Int] = []
360
+ var length = 0
361
362
while num > 0 {
- let remainder = num % 10
- length.append(remainder)
363
+ length += 1
364
num /= 10
365
}
- return length.count
366
+ return length
367
368
369
// Returns the correct string based on the includesValue and includesUnit properties
0 commit comments