exploit nil seqs for performance (#8688)

* changes $ for seqs to never produce 'nil'
* exploit the fact that empty seqs don't have to allocate in the code generator
This commit is contained in:
Andreas Rumpf 2018-08-20 11:54:18 +02:00 • committed by GitHub
commit 2def616069
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
6 changed files with 23 additions and 20 deletions

View file

@ -1,11 +1,11 @@
discard """
output: '''obj2 nil
obj nil
obj3 nil
output: '''obj2 @[]
obj @[]
obj3 @[]
3
obj2 nil
obj nil
obj3 nil'''
obj2 @[]
obj @[]
obj3 @[]'''
cmd: "nim c -r --threads:on $file"
"""

View file

@ -24,7 +24,7 @@ doAssert "nan" == $(0.0/0.0)
# nil tests
# maybe a bit inconsistent in types
var x: seq[string]
doAssert "nil" == $(x)
doAssert "@[]" == $(x)
var y: string
doAssert "" == $(y)