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.
2 parents eaafb67 + 688a00a commit c74229fCopy full SHA for c74229f
Foundation/ByteCountFormatter.swift
@@ -326,15 +326,17 @@ open class ByteCountFormatter : Formatter {
326
327
// A helper method to return the length of an int
328
private func lengthOfInt(number: Int) -> Int {
329
+ guard number != 0 else {
330
+ return 1
331
+ }
332
var num = abs(number)
- var length: [Int] = []
333
+ var length = 0
334
335
while num > 0 {
- let remainder = num % 10
- length.append(remainder)
336
+ length += 1
337
num /= 10
338
}
- return length.count
339
+ return length
340
341
342
// Returns the correct string based on the includesValue and includesUnit properties
0 commit comments