@@ -127,54 +127,27 @@ open class ByteCountFormatter : Formatter {
127
127
let byte = Double ( byteCount)
128
128
if byte == 0 , allowsNonnumericFormatting, allowedUnits == [ ] , includesUnit, includesCount {
129
129
return partsToIncludeFor ( value: " Zero " , unit: . KB)
130
- } else if byte == 1 || byte == - 1 {
131
- if allowedUnits . contains ( . useAll ) || allowedUnits == [ ] {
130
+ } else if allowedUnits . contains ( . useAll ) || allowedUnits == [ ] {
131
+ if byte == 1 || byte == - 1 {
132
132
return formatNumberFor ( bytes: byte, unit: . byte)
133
- } else {
134
- return valueToUseFor ( byteCount: byte, unit: allowedUnits)
135
- }
136
- } else if byte < byteSize [ . KB] ! && byte > - byteSize[ . KB] !{
137
- if allowedUnits. contains ( . useAll) || allowedUnits == [ ] {
133
+ } else if byte < byteSize [ . KB] ! && byte > - byteSize[ . KB] ! {
138
134
return formatNumberFor ( bytes: byte, unit: . bytes)
139
- } else {
140
- return valueToUseFor ( byteCount: byte, unit: allowedUnits)
141
- }
142
- } else if byte < byteSize [ . MB] ! && byte > - byteSize[ . MB] ! {
143
- if allowedUnits. contains ( . useAll) || allowedUnits == [ ] {
135
+ } else if byte < byteSize [ . MB] ! && byte > - byteSize[ . MB] ! {
144
136
return divide ( byte, by: byteSize, for: . KB)
145
- }
146
- return valueToUseFor ( byteCount: byte, unit: allowedUnits)
147
-
148
- } else if byte < byteSize [ . GB] ! && byte > - byteSize[ . GB] ! {
149
- if allowedUnits. contains ( . useAll) || allowedUnits == [ ] {
137
+ } else if byte < byteSize [ . GB] ! && byte > - byteSize[ . GB] ! {
150
138
return divide ( byte, by: byteSize, for: . MB)
151
- }
152
- return valueToUseFor ( byteCount: byte, unit: allowedUnits)
153
-
154
- } else if byte < byteSize [ . TB] ! && byte > - byteSize[ . TB] ! {
155
- if allowedUnits. contains ( . useAll) || allowedUnits == [ ] {
139
+ } else if byte < byteSize [ . TB] ! && byte > - byteSize[ . TB] ! {
156
140
return divide ( byte, by: byteSize, for: . GB)
157
- }
158
- return valueToUseFor ( byteCount: byte, unit: allowedUnits)
159
-
160
- } else if byte < byteSize [ . PB] ! && byte > - byteSize[ . PB] ! {
161
- if allowedUnits. contains ( . useAll) || allowedUnits == [ ] {
141
+ } else if byte < byteSize [ . PB] ! && byte > - byteSize[ . PB] ! {
162
142
return divide ( byte, by: byteSize, for: . TB)
163
- }
164
- return valueToUseFor ( byteCount: byte, unit: allowedUnits)
165
-
166
- } else if byte < byteSize [ . EB] ! && byte > - byteSize[ . EB] ! {
167
- if allowedUnits. contains ( . useAll) || allowedUnits == [ ] {
143
+ } else if byte < byteSize [ . EB] ! && byte > - byteSize[ . EB] ! {
168
144
return divide ( byte, by: byteSize, for: . PB)
169
- }
170
- return valueToUseFor ( byteCount: byte, unit: allowedUnits)
171
-
172
- } else {
173
- if allowedUnits. contains ( . useAll) || allowedUnits == [ ] {
145
+ } else {
174
146
return divide ( byte, by: byteSize, for: . EB)
175
147
}
176
- return valueToUseFor ( byteCount: byte, unit: allowedUnits)
177
148
}
149
+
150
+ return valueToUseFor ( byteCount: byte, unit: allowedUnits)
178
151
}
179
152
180
153
/*
0 commit comments