From a29eb9f0a2d0e98620f660c057e842e544d366ae Mon Sep 17 00:00:00 2001 From: Gibran Chevalley Date: Fri, 8 Nov 2024 14:36:15 +0100 Subject: [PATCH] Simplify else if and its following if in a single condition --- .../swisstransfer/ui/components/HighlighterText.kt | 12 +++++------- 1 file changed, 5 insertions(+), 7 deletions(-) diff --git a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/HighlighterText.kt b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/HighlighterText.kt index abaa580ef..d9fd58d37 100644 --- a/app/src/main/java/com/infomaniak/swisstransfer/ui/components/HighlighterText.kt +++ b/app/src/main/java/com/infomaniak/swisstransfer/ui/components/HighlighterText.kt @@ -149,13 +149,11 @@ private fun TextLayoutResult.getBoundingBoxesForRange(start: Int, end: Int): Lis if (firstLineCharRect == null) { firstLineCharRect = rect - } else if (previousRect != null) { - if (previousRect.bottom != rect.bottom || isLastRect) { - boundingBoxes.add( - firstLineCharRect.copy(right = previousRect.right) - ) - firstLineCharRect = rect - } + } else if (previousRect != null && (previousRect.bottom != rect.bottom || isLastRect)) { + boundingBoxes.add( + firstLineCharRect.copy(right = previousRect.right) + ) + firstLineCharRect = rect } previousRect = rect }