Skip to content

Commit 9b4cc64

Browse files
committed
clean up access calls inside summary
1 parent 2813846 commit 9b4cc64

File tree

1 file changed

+7
-15
lines changed

1 file changed

+7
-15
lines changed

Sources/FoundationEssentials/ProgressManager/ProgressManager+Properties+Accessors.swift

Lines changed: 7 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -422,12 +422,14 @@ extension ProgressManager {
422422
/// where both the value and summary types are `Int`.
423423
/// - Returns: An `Int` summary value for the specified property.
424424
public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == Int, P.Summary == Int {
425-
self.access(keyPath: \.additionalPropertiesSink)
426425
if property.self == ProgressManager.Properties.TotalFileCount.self {
426+
self.access(keyPath: \.totalFileCount)
427427
return updatedFileCount(type: .total)
428428
} else if property.self == ProgressManager.Properties.CompletedFileCount.self {
429+
self.access(keyPath: \.completedFileCount)
429430
return updatedFileCount(type: .completed)
430431
} else {
432+
self.access(keyPath: \.additionalPropertiesSink)
431433
return updatedIntSummary(property: MetatypeWrapper(property))
432434
}
433435
}
@@ -443,16 +445,12 @@ extension ProgressManager {
443445
public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == UInt64, P.Summary == UInt64 {
444446
if property.self == ProgressManager.Properties.TotalByteCount.self {
445447
self.access(keyPath: \.totalByteCount)
446-
} else if property.self == ProgressManager.Properties.CompletedByteCount.self {
447-
self.access(keyPath: \.completedByteCount)
448-
} else {
449-
self.access(keyPath: \.additionalPropertiesSink)
450-
}
451-
if property.self == ProgressManager.Properties.TotalByteCount.self {
452448
return updatedByteCount(type: .total)
453449
} else if property.self == ProgressManager.Properties.CompletedByteCount.self {
450+
self.access(keyPath: \.completedByteCount)
454451
return updatedByteCount(type: .completed)
455452
} else {
453+
self.access(keyPath: \.additionalPropertiesSink)
456454
return updatedUInt64Summary(property: MetatypeWrapper(property))
457455
}
458456
}
@@ -507,12 +505,9 @@ extension ProgressManager {
507505
public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == UInt64, P.Summary == [UInt64] {
508506
if property.self == ProgressManager.Properties.Throughput.self {
509507
self.access(keyPath: \.throughput)
510-
} else {
511-
self.access(keyPath: \.additionalPropertiesSink)
512-
}
513-
if property.self == ProgressManager.Properties.Throughput.self {
514508
return updatedThroughput()
515509
} else {
510+
self.access(keyPath: \.additionalPropertiesSink)
516511
return updatedUInt64ArraySummary(property: MetatypeWrapper(property))
517512
}
518513
}
@@ -528,12 +523,9 @@ extension ProgressManager {
528523
public func summary<P: Property>(of property: P.Type) -> P.Summary where P.Value == Duration, P.Summary == Duration {
529524
if property.self == ProgressManager.Properties.EstimatedTimeRemaining.self {
530525
self.access(keyPath: \.estimatedTimeRemaining)
531-
} else {
532-
self.access(keyPath: \.additionalPropertiesSink)
533-
}
534-
if property.self == ProgressManager.Properties.EstimatedTimeRemaining.self {
535526
return updatedEstimatedTimeRemaining()
536527
} else {
528+
self.access(keyPath: \.additionalPropertiesSink)
537529
return updatedDurationSummary(property: MetatypeWrapper(property))
538530
}
539531
}

0 commit comments

Comments
 (0)