diff options
author | Andreas Rumpf <rumpf_a@web.de> | 2017-09-22 09:57:18 +0200 |
---|---|---|
committer | Andreas Rumpf <rumpf_a@web.de> | 2017-09-22 09:57:18 +0200 |
commit | c383e4d35e4993f4cf094f984ae6acbd3f892a8b (patch) | |
tree | 1554d5f923119299f616fdf57088359838ebc573 /lib/system.nim | |
parent | 3936587c06c60e57481952452b8258e8c5d58684 (diff) | |
download | Nim-c383e4d35e4993f4cf094f984ae6acbd3f892a8b.tar.gz |
preparations for string optimizations
Diffstat (limited to 'lib/system.nim')
-rw-r--r-- | lib/system.nim | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/lib/system.nim b/lib/system.nim index a4460570a..cc5ef9810 100644 --- a/lib/system.nim +++ b/lib/system.nim @@ -409,8 +409,7 @@ when not defined(JS): when not defined(JS) and not defined(nimscript): template space(s: PGenericSeq): int {.dirty.} = - s.reserved and not seqShallowFlag - + s.reserved and not (seqShallowFlag or strlitFlag) include "system/hti" type @@ -1329,6 +1328,9 @@ const ## "amd64", "mips", "mipsel", "arm", "arm64", "mips64", "mips64el". seqShallowFlag = low(int) + strlitFlag = 1 shl (sizeof(int)*8 - 2) # later versions of the codegen \ + # emit this flag + # for string literals, it allows for some optimizations. {.push profiler: off.} when defined(nimKnowsNimvm): @@ -3720,7 +3722,9 @@ proc shallow*(s: var string) {.noSideEffect, inline.} = ## purposes. when not defined(JS) and not defined(nimscript): var s = cast[PGenericSeq](s) - s.reserved = s.reserved or seqShallowFlag + # string literals cannot become 'shallow': + if (s.reserved and strlitFlag) == 0: + s.reserved = s.reserved or seqShallowFlag type NimNodeObj = object |