diff --git a/adix/althash.nim b/adix/althash.nim index 5a8cd0d..f2c4417 100644 --- a/adix/althash.nim +++ b/adix/althash.nim @@ -52,6 +52,7 @@ ## hashes or `a` alone can similarly mislead. TLDR, want >=2 "summary numbers" ## not one & whole curves are best. +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 import std/hashes, bitop # For the Hash type and system `hash()`es export Hash, `!$`, hash diff --git a/adix/amoft.nim b/adix/amoft.nim index 86d6baf..b420889 100644 --- a/adix/amoft.nim +++ b/adix/amoft.nim @@ -8,6 +8,7 @@ ## for i in 0..<500: amo.inc i, i # Not v.skewed => not v.accurate ## for (i, c) in amo.mostCommon(5): echo i, " ", c +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 import std/[hashes, heapqueue, tables, algorithm] type CtMnSketch*[K,C] = object ## CountMinSketch over hashable `K` & counters `C`. diff --git a/adix/bitop.nim b/adix/bitop.nim index 6559c4b..7b8f129 100644 --- a/adix/bitop.nim +++ b/adix/bitop.nim @@ -1,5 +1,6 @@ ## This is a reimplementation of some things we need from bitops which has CT ## trouble due to importc's. (I feel it's a better naming/factoring, too). +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 proc ceilPow2*(x: int): int {.noSideEffect, inline.} = ## Returns ``x`` rounded up to the nearest power of two. <= 0 get 1. diff --git a/adix/bltab.nim b/adix/bltab.nim index fb090d9..96cda43 100644 --- a/adix/bltab.nim +++ b/adix/bltab.nim @@ -5,6 +5,7 @@ ## Bits for values and the sentinel key default to 0. `BLTab` otherwise tries to ## be similar to hash variants of multisets. +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 import althash, sequint when not declared(stderr): import std/assertions type diff --git a/adix/btree.nim b/adix/btree.nim index 4b8b649..3e15125 100644 --- a/adix/btree.nim +++ b/adix/btree.nim @@ -69,6 +69,7 @@ ## Nim TODOs incl: make easy to include inside other generic types, add easy ## HashSet & Table use in terms of this lower-level core, run-tm ->CT errs, do ## GC'd&memfiles Ln variants, do distinct int `Ln` for ovrld/figure out exports. +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 when not declared(stderr): import std/syncio proc orderFit*(target, wtSz, ixSz, obSz, lnSz: int): int = diff --git a/adix/cumsum.nim b/adix/cumsum.nim index fd53f6d..50708d9 100644 --- a/adix/cumsum.nim +++ b/adix/cumsum.nim @@ -1,3 +1,4 @@ +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 import adix/cpuCT proc `[]`[C, W](h: ptr UncheckedArray[C], i: W): var C {.inline.} = diff --git a/adix/ditab.nim b/adix/ditab.nim index 39f2b4d..0c0e087 100644 --- a/adix/ditab.nim +++ b/adix/ditab.nim @@ -21,6 +21,7 @@ ## under another term like "direct indexing". `K` below must have an available ## conversion to ``int``. Duplicate keys cannot be allowed for this one. +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 import althash, sequint, topk; export topk.TopKOrder when not declared(assert): import std/assertions type diff --git a/adix/lghisto.nim b/adix/lghisto.nim index e3c83ac..f41e2d2 100644 --- a/adix/lghisto.nim +++ b/adix/lghisto.nim @@ -27,6 +27,7 @@ ## Bollinger Band style smooths. Second, floating point weights for EWMA-like ## decaying memory are not possible since FP arithmetic kind of breaks BISTs. +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 when not declared(addFloat): import std/formatfloat import adix/bist, std/math type diff --git a/adix/lptabz.nim b/adix/lptabz.nim index 7fcbcc2..74033d2 100644 --- a/adix/lptabz.nim +++ b/adix/lptabz.nim @@ -35,6 +35,7 @@ ## `seq[(K,V)]`. 6..8 bits avoids most "double cache misses" for miss ## lookups/inserts. `z=0` works if space matters more than time. +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 import althash, memutil, bitop, topk, sequint, std/[strutils, memfiles] export Hash, sequint, topk.TopKOrder when not declared(assert): import std/[assertions, objectdollar] @@ -479,7 +480,7 @@ proc setCap*[K,V,Z;z:static int](t: var LPTabz[K,V,Z,z]; newSize = -1) = if t.rehash: t.salt = getSalt(old[0].addr) swap(t.data, old) when Z is K: - var hc: Hash + var hc = 0.Hash if K(z) != K(0): for i in 0 ..< t.getCap: t.unUse(i, false) for cell in old.mitems: @@ -504,7 +505,7 @@ proc setCap*[K,V,Z;z:static int](t: var LPTabz[K,V,Z,z]; newSize = -1) = template getPut(t, i, key, present, missing: untyped): untyped = mixin rawPut1, rawPut2, tooFull, getCap, init, setCap if t.getCap == 0: t.init - var hc, d, newSize: Hash + var hc, d, newSize: Hash = 0 var i = t.rawGet(key, hc, d) if i < 0: var j = t.rawPut1(-1 - i, d) @@ -701,7 +702,7 @@ proc editKey*[K,V,Z;z:static int](t: var LPTabz[K,V,Z,z]; old, new: K) = t.data[k].key = new var hc, d: Hash let j = t.rawGetDeep(new, hc, d) #Allow `new` to be a dup key - var newSize: int + var newSize = 0 if t.tooFull(d, newSize): t.setCap newSize #`new` already in `data`; setCap does rest else: #else point-edit new key index into table diff --git a/adix/mvstat.nim b/adix/mvstat.nim index b5542cb..3640d88 100644 --- a/adix/mvstat.nim +++ b/adix/mvstat.nim @@ -11,6 +11,7 @@ ## equivalents but has precise rather than infinite memory which can be nice. ## I.e., it can perfectly "forget" a large spike when it leaves a window. +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 when not declared(addFloat): import std/objectdollar from std/math import sqrt, sum, `^` from std/strutils import formatFloat, ffDefault diff --git a/adix/nim.cfg b/adix/nim.cfg index 10bc68c..466b7f3 100644 --- a/adix/nim.cfg +++ b/adix/nim.cfg @@ -1,3 +1,2 @@ path=".." -warning[Uninit]:off -warning[ProveInit]:off +warning[Uninit]:off warning[ProveInit]:off # Should be verbosity:2, not 1 diff --git a/adix/nsort.nim b/adix/nsort.nim index d923a35..153464a 100644 --- a/adix/nsort.nim +++ b/adix/nsort.nim @@ -54,6 +54,7 @@ ## also needs inverse transforms on the final pass & current xforms are already ## cheap compared to L2 or worse bandwidth costs. So, 5-20% boost, I'd guess.) +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 when not declared(stdout): import std/syncio import adix/[cpuCT, cumsum], std/[bitops, math, algorithm] when defined(cpuPrefetch): import cligen/prefetch # Keep cligen a soft-dep diff --git a/adix/oats.nim b/adix/oats.nim index a22a344..a0852e8 100644 --- a/adix/oats.nim +++ b/adix/oats.nim @@ -1,3 +1,4 @@ +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 import std/hashes, adix/[bitop, topk]; export topk.TopKOrder type # More adaptable than Nim std/sets|tables (named ROats|VROats here) Oat*[K, Q] = concept t # Base Concept: Open-Addressed Table @@ -67,6 +68,7 @@ proc oatSlot*[K,Q](t: Oat[K,Q]; q: Q; h: Hash; d: var Hash): int = proc tooFull*[K,Q](t: Oat[K,Q]; d: int; newSize: var int): bool = #-> user proc w/some provided default BUT there's a circular dep through `len` + newSize = 0 let sLen=t.len # Could be a cap-long loop if sLen + 1 + 1 > t.cap: # Call setCap pre-put? +1 new, +1 free newSize = t.cap shl 1; return true @@ -81,7 +83,7 @@ proc setCap*[K,Q](t: var ROat[K,Q]; newSize = -1) = else: oatSlots(max(newSize, t.len), 1) # max blocks over-shrink if newSz == t.cap and newSize == -1: return var ns = t.newOfCap newSz - var d: int + var d = 0 for i in 0 ..< t.cap: if t.used i: let q = t.key i @@ -90,7 +92,7 @@ proc setCap*[K,Q](t: var ROat[K,Q]; newSize = -1) = t.setNew ns template upSert*[K,Q](t: var Oat[K,Q], q, i, UP, SERT) = - var d, newSize: Hash + var newSize {.noinit.}, d: Hash let h = q.hash var i = oatSlot(t, q, h, d) if i >= 0: UP diff --git a/adix/sequint.nim b/adix/sequint.nim index 851fcbe..8b1b5c2 100644 --- a/adix/sequint.nim +++ b/adix/sequint.nim @@ -28,6 +28,7 @@ # few use (since impls are just not handy or may be slow). Thus it is not a bad # choice for Nim stdlib inclusion, especially with per CPU speed forks. +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 import bitop const iBit = 8 * sizeof(int) const iShf = lgPow2(iBit) diff --git a/adix/tdigest.nim b/adix/tdigest.nim index 8ae83a7..ded899e 100644 --- a/adix/tdigest.nim +++ b/adix/tdigest.nim @@ -6,6 +6,7 @@ ## adapt my B-Tree to speed up the idea. { tDig is also very involved - folks ## just *intuit* histo(ln(x)), but that is a more subjective critique. } +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 when not declared(addFloat): import std/formatfloat import std/[math, algorithm] type diff --git a/adix/topk.nim b/adix/topk.nim index b92dcee..3661b4e 100644 --- a/adix/topk.nim +++ b/adix/topk.nim @@ -1,3 +1,4 @@ +{.warning[Uninit]:off, warning[ProveInit]:off.} # Should be verbosity:2, not 1 import std/[random, algorithm] # quickwit.io/blog/top-k-complexity explains BUT type #..NOTE heap [θO](n*lg k) &this θ(n),O(n*lg k). Partn* = enum last, ran #XXX Tukey's 9th | median-of-medians | PDQ? @@ -16,7 +17,7 @@ proc initTopK*[T](k=10, partn=last): TopK[T] = ## .. code-block:: nim ## var t = initTopK(); for e in 1..99: t.push e ## for e in t: echo e - result.i = -1; result.k = k; result.partn = partn; result.first = true + result = TopK[T](i: -1, k: k, partn: partn, first: true) when supportsCopyMem(T) and declared newSeqUninit: result.s = newSeqUninit[T](2*k); result.s.setLen 0 diff --git a/tests/nim.cfg b/tests/nim.cfg index c7da59b..2a23d83 100644 --- a/tests/nim.cfg +++ b/tests/nim.cfg @@ -1,3 +1,4 @@ path=".." path="../adix" path="../../cg" # cligen +warning[Uninit]:off warning[ProveInit]:off # Should be verbosity:2, not 1 diff --git a/tests/ucl.nim b/tests/ucl.nim index 5be1d7a..dd472c6 100644 --- a/tests/ucl.nim +++ b/tests/ucl.nim @@ -37,7 +37,7 @@ proc incFailed(h: var Counts, ms: MSlice): bool = proc ucl(size=9999, dSize=81920, tm=false) = ## Count unique & total lines on `stdin`. <256B long; <16 MiB unique data. let t0 = if tm: epochTime() else: 0.0 - var h: Counts; h.setCap size # pre-size table & data + var h=Counts(); h.setCap size # pre-size table & data s.setLen dSize; s.setLen 1 var nTot = 0 block IO: diff --git a/tests/wf.nim b/tests/wf.nim index 84411c8..1efba7c 100644 --- a/tests/wf.nim +++ b/tests/wf.nim @@ -41,12 +41,12 @@ proc `<`(a, b: Word): bool {.inline.} = # for topk.push if c == 0: a.len < b.len else: c < 0 proc `$`(w: Word): string = # for output - result.setLen w.len - copyMem result[0].addr, w.mem, w.len + result = newString(w.len) + copyMem result.cstring, w.mem, w.len when defined(benhoyt): # Ben Hoyt definition of "words" iterator lowCaseWords(ms: MSlice): Word = - var wd, n: int + var wd, n: int = 0 for i, ch in ms: if ch in {'A'..'Z'}: # `tr A-Z a-z` preprocess to avoid ms[i] = char(ord(ch) + 32) # needs MAP_PRIVATE @@ -60,7 +60,7 @@ when defined(benhoyt): # Ben Hoyt definition of "words" if n > 0: yield initWord(wd, n) # any final word else: # Knuth-McIlroy definition of "words" iterator lowCaseWords(ms: MSlice): Word = - var wd, n: int + var wd, n: int = 0 for i, ch in ms: if ch in {'a'..'z'}: # in-word ch if n == 0: wd = (ms.mem +! i) -! mf.mem diff --git a/tests/wfr.nim b/tests/wfr.nim index 74cf25a..0e36c3b 100644 --- a/tests/wfr.nim +++ b/tests/wfr.nim @@ -47,7 +47,7 @@ proc wfr(n=10, count=false,Norm=false, size=9999,dSize=81920, tm=false, Dlm="")= ## Histogram words on `stdin`. <128 MiB unique data; <32B long; <4 GiCount. let sep = initSep(if Dlm.len != 0: Dlm else: d) let t0 = if tm: epochTime() else: 0.0 - var h: Counts; h.setCap size # pre-size table & data + var h=Counts(); h.setCap size # pre-size table & data s.setLen dSize; s.setLen 0 var nTot = 0 block IO: diff --git a/tests/wu.nim b/tests/wu.nim index 2d152cb..044b5f2 100644 --- a/tests/wu.nim +++ b/tests/wu.nim @@ -39,7 +39,7 @@ proc wu(size=9999,dSize=81920, tm=false, Dlm="") = ## Count unique & total words on `stdin`. <32B long; <128 MiB unique data. let sep = initSep(if Dlm.len != 0: Dlm else: d) let t0 = if tm: epochTime() else: 0.0 - var h: Counts; h.setCap size # pre-size table & data + var h=Counts(); h.setCap size # pre-size table & data s.setLen dSize; s.setLen 0 var nTot = 0 block IO: diff --git a/util/lfreq.nim b/util/lfreq.nim index bd20b14..a2428a0 100644 --- a/util/lfreq.nim +++ b/util/lfreq.nim @@ -46,7 +46,7 @@ proc lfreq(n=10, count=false, size=9999, dSize=81920, recTerm='\n', ## Histogram `stdin` lines (read w/non-memory mapped IO to be pipe friendly). ## Limits: <4 GiB unique data; <16 KiB lines; <4 GiCount. let t0 = if tm: epochTime() else: 0.0 - var h: Counts; h.setCap size # pre-size table & data + var h=Counts(); h.setCap size # pre-size table & data s.setLen dSize; s.setLen 0 var nTot = 0 block IO: diff --git a/util/nim.cfg b/util/nim.cfg index 72b8423..466b7f3 100644 --- a/util/nim.cfg +++ b/util/nim.cfg @@ -1 +1,2 @@ path=".." +warning[Uninit]:off warning[ProveInit]:off # Should be verbosity:2, not 1