Use the cached layout wrapper if it exists
Summary: - We cache the layout wrapper, but never used it actually. - This should make the Layout plugin faster. Reviewed By: fabiomassimo Differential Revision: D15046463 fbshipit-source-id: b61f28d9a981e782b76abe78037d37665f7d8ba3
This commit is contained in:
committed by
Facebook Github Bot
parent
c764322c1a
commit
1c35b705eb
@@ -45,12 +45,21 @@ static CKFlexboxComponentChild findFlexboxLayoutParams(CKComponent *parent, CKCo
|
||||
|
||||
+ (instancetype)newFromRoot:(id<CKInspectableView>)root {
|
||||
const CKComponentLayout layout = [root mountedLayout];
|
||||
// Check if there is a cached wrapper.
|
||||
if (layout.component) {
|
||||
SKComponentLayoutWrapper *cachedWrapper = objc_getAssociatedObject(layout.component, &kLayoutWrapperKey);
|
||||
if (cachedWrapper) {
|
||||
return cachedWrapper;
|
||||
}
|
||||
}
|
||||
CKComponentReuseWrapper *reuseWrapper = CKAnalyticsListenerHelpers::GetReusedNodes(layout.component);
|
||||
// Create a new layout wrapper.
|
||||
SKComponentLayoutWrapper *const wrapper =
|
||||
[[SKComponentLayoutWrapper alloc] initWithLayout:layout
|
||||
position:CGPointMake(0, 0)
|
||||
parentKey:[NSString stringWithFormat: @"%p.", layout.component]
|
||||
reuseWrapper:reuseWrapper];
|
||||
// Cache the result.
|
||||
if (layout.component) {
|
||||
objc_setAssociatedObject(layout.component, &kLayoutWrapperKey, wrapper, OBJC_ASSOCIATION_RETAIN_NONATOMIC);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user