aboutsummaryrefslogtreecommitdiffstats
path: root/src/css
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2024-12-13 20:58:08 +0100
committerbptato <nincsnevem662@gmail.com>2024-12-13 21:41:45 +0100
commit92382f8145f71708d4ecaf7808efb59811d52343 (patch)
tree551d3d272825defed96d1fea0734d5d7117bf547 /src/css
parentca67e39af501c959c44855e447c7d1b191ee38d3 (diff)
downloadchawan-92382f8145f71708d4ecaf7808efb59811d52343.tar.gz
lunit: remove redundant code
using div instead of / is sort of weird, but it makes it clearer if we're dividing floats or layoutunits (and is already what the code uses).
Diffstat (limited to 'src/css')
-rw-r--r--src/css/layout.nim2
-rw-r--r--src/css/lunit.nim6
2 files changed, 2 insertions, 6 deletions
diff --git a/src/css/layout.nim b/src/css/layout.nim
index c92f7cbc..f32cba2c 100644
--- a/src/css/layout.nim
+++ b/src/css/layout.nim
@@ -2059,7 +2059,7 @@ func calcSpecifiedRatio(tctx: TableContext; W: LayoutUnit): LayoutUnit =
# rest of the space.
if totalSpecified == 0 or W > totalSpecified and hasUnspecified:
return 1
- return W / totalSpecified
+ return W div totalSpecified
proc calcUnspecifiedColIndices(tctx: var TableContext; W: var LayoutUnit;
weight: var float64): seq[int] =
diff --git a/src/css/lunit.nim b/src/css/lunit.nim
index 1b526fb7..8557f7ee 100644
--- a/src/css/lunit.nim
+++ b/src/css/lunit.nim
@@ -14,14 +14,10 @@ func `*`*(a, b: LayoutUnit): LayoutUnit {.inline.} =
LayoutUnit((int32(a) * int32(b)) shr 6)
func `*=`*(a: var LayoutUnit, b: LayoutUnit) {.inline.} =
a = a * b
-func `/`*(a, b: LayoutUnit): LayoutUnit {.inline.} =
+func `div`*(a, b: LayoutUnit): LayoutUnit {.inline.} =
let a64 = int64(a)
let b64 = int64(b)
LayoutUnit(cast[int32](((a64 shl 12) div b64) shr 6))
-func `/=`*(a: var LayoutUnit, b: LayoutUnit) {.inline.} =
- a = a / b
-func `div`*(a, b: LayoutUnit): LayoutUnit {.inline.} =
- a / b
func toInt*(a: LayoutUnit): int =
return int32(a) shr 6