diff options
author | bptato <nincsnevem662@gmail.com> | 2023-12-13 13:29:42 +0100 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2023-12-13 13:29:42 +0100 |
commit | df40fcdde896f636a05d1e3fe598feb2a816f2b9 (patch) | |
tree | cc8ffa2729d5e3b078782047d87bdb9019e349e9 /src/utils/map.nim | |
parent | ab203acf554993d15e37604773f160c84b4d8252 (diff) | |
download | chawan-df40fcdde896f636a05d1e3fe598feb2a816f2b9.tar.gz |
break up twtstr somewhat
Avoid computing e.g. charwidth data for http which does not need it at all.
Diffstat (limited to 'src/utils/map.nim')
-rw-r--r-- | src/utils/map.nim | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/src/utils/map.nim b/src/utils/map.nim index 526b9154..2a3515a1 100644 --- a/src/utils/map.nim +++ b/src/utils/map.nim @@ -1,15 +1,15 @@ import algorithm -func searchInMap*[U, T](a: openarray[(U, T)], u: U): int = +func searchInMap*[U, T](a: openArray[(U, T)], u: U): int = when not (typeof(u) is U): if c > cast[typeof(c)](high(U)): return -1 binarySearch(a, u, proc(x: (U, T), y: U): int = cmp(x[0], y)) -func isInMap*[U, T](a: openarray[(U, T)], u: U): bool = +func isInMap*[U, T](a: openArray[(U, T)], u: U): bool = a.searchInMap(u) != -1 -func isInRange*[U](a: openarray[(U, U)], u: U): bool = +func isInRange*[U](a: openArray[(U, U)], u: U): bool = let res = binarySearch(a, u, proc(x: (U, U), y: U): int = if x[0] < y: -1 |