From a66169f48dc2821f63756661d3a0b0151671b9da Mon Sep 17 00:00:00 2001 From: Max Wang Date: Mon, 13 Sep 2021 19:03:22 -0700 Subject: [PATCH] avoid padding a struct to be hashed --- Source/Details/ASCollectionLayoutContext.mm | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/Source/Details/ASCollectionLayoutContext.mm b/Source/Details/ASCollectionLayoutContext.mm index 6f2ba7186..2d0b153f9 100644 --- a/Source/Details/ASCollectionLayoutContext.mm +++ b/Source/Details/ASCollectionLayoutContext.mm @@ -85,7 +85,9 @@ - (NSUInteger)hash { struct { CGSize viewportSize; - ASScrollDirection scrollableDirections; + // Fields must be aligned without padding, otherwise hash result will be different for the same + // struct. That's why we use NSUInteger instead of ASScrollDirection. + NSUInteger scrollableDirections; NSUInteger elementsHash; NSUInteger layoutDelegateClassHash; NSUInteger additionalInfoHash;