Skip to content
Browse files

Don't set cell frames as often

  • Loading branch information...
1 parent 86398f4 commit f2b2133f0833494f6f3df790a31091cfdec1cdab Zach Drayer committed Mar 19, 2012
Showing with 8 additions and 3 deletions.
  1. +6 −2 KKGridView/Definitions.h
  2. +2 −1 KKGridView/KKGridView.m
View
8 KKGridView/Definitions.h
@@ -22,12 +22,16 @@
#define __kk_weak __unsafe_unretained
#endif
-static inline bool KKCGRectIntersectsRectVertically(CGRect rect1, CGRect rect2)
+#if !defined(KKInline)
+#define KKInline static __inline__ __attribute__((always_inline))
+#endif
+
+KKInline BOOL KKCGRectIntersectsRectVertically(CGRect rect1, CGRect rect2)
{
return (CGRectGetMinY(rect2) < CGRectGetMaxY(rect1)) && (CGRectGetMaxY(rect2) > CGRectGetMinY(rect1));
}
-static inline bool KKCGRectIntersectsRectVerticallyWithPositiveNegativeMargin(CGRect rect1, CGRect rect2, CGFloat margin)
+KKInline BOOL KKCGRectIntersectsRectVerticallyWithPositiveNegativeMargin(CGRect rect1, CGRect rect2, CGFloat margin)
{
return (CGRectGetMinY(rect2) - margin < CGRectGetMaxY(rect1)) && (CGRectGetMaxY(rect2) + margin > CGRectGetMinY(rect1));
}
View
3 KKGridView/KKGridView.m
@@ -604,7 +604,8 @@ - (void)_cleanupCells
KKGridViewCell *cell = pair.cell;
[self _enqueueCell:cell withIdentifier:cell.reuseIdentifier];
- cell.frame = (CGRect){.size = _cellSize};
+ if (!CGSizeEqualToSize(_cellSize, cell.frame.size))
+ cell.frame = (CGRect){.size = _cellSize};
cell.hidden = YES;
cell.alpha = 0.;

0 comments on commit f2b2133

Please sign in to comment.
Something went wrong with that request. Please try again.