diff options
author | Danil Yarantsev <tiberiumk12@gmail.com> | 2022-04-25 12:15:03 +0300 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-04-25 11:15:03 +0200 |
commit | 2f32b450d39030c287df4d56be9d06473772f5cd (patch) | |
tree | 4c634f5ab10090c3961f12fa1b301eb74e127f87 /lib/pure | |
parent | efaa6777a464b94d88cb948390397b490ccee5b8 (diff) | |
download | Nim-2f32b450d39030c287df4d56be9d06473772f5cd.tar.gz |
Really fix StringStream with ARC at compile-time, improve streams test (#19739)
* Fix compile-time StringStream with ARC * make readDataStr work with ARC, improve test
Diffstat (limited to 'lib/pure')
-rw-r--r-- | lib/pure/streams.nim | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/lib/pure/streams.nim b/lib/pure/streams.nim index 2ac6a82f1..f58273ee8 100644 --- a/lib/pure/streams.nim +++ b/lib/pure/streams.nim @@ -243,6 +243,9 @@ proc readDataStr*(s: Stream, buffer: var string, slice: Slice[int]): int = result = s.readDataStrImpl(s, buffer, slice) else: # fallback + when declared(prepareMutation): + # buffer might potentially be a CoW literal with ARC + prepareMutation(buffer) result = s.readData(addr buffer[slice.a], slice.b + 1 - slice.a) template jsOrVmBlock(caseJsOrVm, caseElse: untyped): untyped = @@ -1274,8 +1277,11 @@ else: # after 1.3 or JS not defined new(result) result.data = s - when declared(prepareMutation): - prepareMutation(result.data) # Allows us to mutate using `addr` logic like `copyMem`, otherwise it errors. + when nimvm: + discard + else: + when declared(prepareMutation): + prepareMutation(result.data) # Allows us to mutate using `addr` logic like `copyMem`, otherwise it errors. result.pos = 0 result.closeImpl = ssClose result.atEndImpl = ssAtEnd |