-
Notifications
You must be signed in to change notification settings - Fork 11
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Reusability hint to improve reuse performance when composite componen…
…ts are present.
- Loading branch information
Showing
9 changed files
with
247 additions
and
19 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
public struct ReusabilityHintCombiner { | ||
internal var types: [Any.Type] | ||
|
||
internal init<R: Renderable>(root: R) { | ||
types = [root.componentType] | ||
} | ||
|
||
public mutating func combine<R: Renderable>(_ component: R) { | ||
types.append(component.componentType) | ||
component.makeReusabilityHint(using: &self) | ||
} | ||
|
||
__consuming func generate() -> String { | ||
return types.map(fullyQualifiedTypeName(of:)).joined(separator: ",") | ||
} | ||
|
||
__consuming func isCompatible(with other: __owned ReusabilityHintCombiner) -> Bool { | ||
return types.elementsEqual(other.types, by: ==) | ||
} | ||
} | ||
|
||
|
||
func fullyQualifiedTypeName(of type: Any.Type) -> String { | ||
/// NOTE: `String.init(reflecting:)` gives the fully qualified type name. | ||
// Tests would catch unexpeced type name printing behavior due to Swift runtime changes. | ||
return String(reflecting: type) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.