Cosmetic compiler cleanup (#12718)

* Cleanup compiler code base

* Unify add calls

* Unify len invocations

* Unify range operators

* Fix oversight

* Remove {.procvar.} pragma

* initCandidate -> newCandidate where reasonable

* Unify safeLen calls
This commit is contained in:
Clyybber 2019-11-28 17:13:04 +01:00 • committed by Andreas Rumpf
commit 7e747d11c6
109 changed files with 6115 additions and 6254 deletions

View file

@ -20,14 +20,13 @@ proc prefixMatch*(p, s: string): PrefixMatch =
template eq(a, b): bool = a.toLowerAscii == b.toLowerAscii
if p.len > s.len: return PrefixMatch.None
var i = 0
let L = s.len
# check for prefix/contains:
while i < L:
while i < s.len:
if s[i] == '_': inc i
if i < L and eq(s[i], p[0]):
if i < s.len and eq(s[i], p[0]):
var ii = i+1
var jj = 1
while ii < L and jj < p.len:
while ii < s.len and jj < p.len:
if p[jj] == '_': inc jj
if s[ii] == '_': inc ii
if not eq(s[ii], p[jj]): break