From cafb9dcc3ba6054a3ecba1798c34236ecfa8b592 Mon Sep 17 00:00:00 2001 From: Tamim Attafi Date: Sat, 20 Feb 2021 17:14:17 +0700 Subject: [PATCH] Experiment: Changed rect hash code computation --- .../neumorphism/internal/shape/ShapeFactory.kt | 14 +++++--------- 1 file changed, 5 insertions(+), 9 deletions(-) diff --git a/neumorphism/src/main/java/soup/neumorphism/internal/shape/ShapeFactory.kt b/neumorphism/src/main/java/soup/neumorphism/internal/shape/ShapeFactory.kt index c296346..f38d379 100644 --- a/neumorphism/src/main/java/soup/neumorphism/internal/shape/ShapeFactory.kt +++ b/neumorphism/src/main/java/soup/neumorphism/internal/shape/ShapeFactory.kt @@ -82,23 +82,19 @@ internal object ShapeFactory { } private fun Rect.calculateHashCode(sizeStep: Int): Int { - var result = left / sizeStep - result = 31 * result + top / sizeStep - result = 31 * result + right / sizeStep - result = 31 * result + bottom / sizeStep + var result = width() / sizeStep + result = 31 * result + height() / sizeStep return result } private fun RectF.calculateHashCode(sizeStep: Int): Int { - var result = if (left != 0.0f) java.lang.Float.floatToIntBits(left) / sizeStep else 0 - result = 31 * result + if (top != 0.0f) java.lang.Float.floatToIntBits(top) / sizeStep else 0 - result = 31 * result + if (right != 0.0f) java.lang.Float.floatToIntBits(right) / sizeStep else 0 - result = 31 * result + if (bottom != 0.0f) java.lang.Float.floatToIntBits(bottom) / sizeStep else 0 + var result = width().toInt() / sizeStep + result = 31 * result + height().toInt() / sizeStep return result } object Parameters { - const val SIZE_CACHING_STEP = 100 + const val SIZE_CACHING_STEP = 24 } } \ No newline at end of file