mirror of
https://github.com/nim-lang/Nim.git
synced 2026-05-04 21:14:48 +00:00
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
(cherry picked from commit 2f32b450d3)
This commit is contained in:
committed by
narimiran
parent
151b4cc514
commit
b1045cb693
@@ -240,6 +240,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 =
|
||||
@@ -1271,8 +1274,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
|
||||
|
||||
Reference in New Issue
Block a user