about summary refs log tree commit diff stats
path: root/src/types/path.nim
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2025-01-22 20:32:22 +0100
committerbptato <nincsnevem662@gmail.com>2025-01-22 20:32:22 +0100
commitf53a20f12bf07844402ece62c920c8dfbc6cb825 (patch)
tree043cdb4b1b43fa0e9d27a8212f8c8a330b5cf8f0 /src/types/path.nim
parent9df15b2b3c5a7897d2314c0b68a4faf05b8d7459 (diff)
downloadchawan-f53a20f12bf07844402ece62c920c8dfbc6cb825.tar.gz
Add annotations for move semantics
Supposedly they aren't broken in refc after 2.0.0, so we can do this now
that 1.6.14 is dropped.

I've confirmed lent to work as advertised; it indeed reduces copies.
sink doesn't seem to help much, but I guess it will be useful once we
switch to ORC.
Diffstat (limited to 'src/types/path.nim')
-rw-r--r--src/types/path.nim7
1 files changed, 4 insertions, 3 deletions
diff --git a/src/types/path.nim b/src/types/path.nim
index 4bf14adc..dba83a26 100644
--- a/src/types/path.nim
+++ b/src/types/path.nim
@@ -242,12 +242,13 @@ func flatEnough(a, b, c0, c1: Vector2D): bool =
   let vy = 3 * c1.y - a.y - 2 * b.y
   return max(ux * ux, vx * vx) + max(uy * uy, vy * vy) <= 0.02
 
-iterator items*(pl: PathLines): LineSegment {.inline.} =
+iterator items*(pl: PathLines): lent LineSegment {.inline.} =
   for line in pl.lines:
     yield line
 
-func `[]`*(pl: PathLines; i: int): LineSegment = pl.lines[i]
-func `[]`*(pl: PathLines; i: BackwardsIndex): LineSegment = pl.lines[i]
+func `[]`*(pl: PathLines; i: int): lent LineSegment = pl.lines[i]
+func `[]`*(pl: PathLines; i: BackwardsIndex): lent LineSegment =
+  return pl.lines[pl.lines.len - int(i)]
 func len*(pl: PathLines): int = pl.lines.len
 
 iterator quadraticLines(a, b, c: Vector2D): Line {.inline.} =