LinkedInAttic / LayoutKit

LayoutKit is a fast view layout library for iOS, macOS, and tvOS.
http://layoutkit.org
Apache License 2.0
3.16k stars 267 forks source link

Fix a recycling bug that purges indirect subviews #243

Open Biinngg opened 6 years ago

Biinngg commented 6 years ago

Only walk first level of subviews that are created by LayoutKit. If a subview isn't created by LayoutKit, then there is no need to walk subviews of it, as they must not be created by this layout.

staguer commented 6 years ago

Oh, this looks like a good improvement, thanks!

I have a couple of points:

  1. This avoids traversing rootView -> nonLayoutKitView -> otherLayoutKitViews, right? What if we had rootView -> LayoutKitView -> nonLayoutKitView -> otherLayoutKitViews? Perhaps we should do this check at every level?
  2. Do we need to check $0.isLayoutKitView || $0.viewReuseId != nil or is it sufficient to just check $0.isLayoutKitView?
  3. I liked your comment at the start of this Pull Request here, can you please add the comment to the code as well, explaining why it’s important to have the check and what problem it avoids?

Thank you!

Biinngg commented 6 years ago

Hi Sergei, Thanks for your review. Your points sound good. I updated my PR to include those changes. Thanks!