raz / commit e57d9c7e

commit
e57d9c7e0655a9a55d15767d39713e85d67927b5
author
Luis <42945842+ldiaz94@users.noreply.github.com>
date
parent
b4f0595e
PROPOSALS: Map.done, met in rwalk

patch · log

1 file changed, +23 -0

PROPOSALS.md modified +23 -0

@@ -513,3 +513,26 @@
513513
514514 Met in rless, whose `make rless-c` builds over the C `Sys` without
515515 `-Werror` for this alone.
516+
517+## `Map.done`
518+
519+`Map` takes memory from its allocator as it grows and frees the old
520+slots, but never gives the last ones back: a map made over `Heap` for
521+a while, as a table kept for one directory of a walk, can't be
522+emptied of its memory, only dropped, and the memory is lost. `Buf`
523+and `Vec` each have a `done`; `Map` has none, and is the odd one out.
524+
525+```
526+proc done*(m: ^Map); (* its memory given back, leaving it empty *)
527+```
528+
529+As `Vec.done`: free the slots if there are any, then `cap` and `len`
530+0, so the map can be used again and grows anew. `init` already leaves
531+it so, with no memory taken until the first `put`.
532+
533+Met in rwalk's `Rwignore`, which keeps a table of the rules that are a
534+plain name (`node_modules`, `target`) for each ignore file, made as the
535+walk enters a directory and dropped as it leaves. Without `done` it
536+used a `Vec` of rule numbers instead, searched in turn. Library growth
537+that breaks no program; about ten lines, with a test in `Map`'s
538+`main`.