Make MemSlice stringification both simpler and faster. (#10464)
This commit is contained in:
parent
3ce6b2acb9
commit
322f395f31
1 changed files with 2 additions and 3 deletions
|
|
@ -372,9 +372,8 @@ proc `==`*(x, y: MemSlice): bool =
|
||||||
|
|
||||||
proc `$`*(ms: MemSlice): string {.inline.} =
|
proc `$`*(ms: MemSlice): string {.inline.} =
|
||||||
## Return a Nim string built from a MemSlice.
|
## Return a Nim string built from a MemSlice.
|
||||||
var buf = newString(ms.size)
|
result.setLen(ms.size)
|
||||||
copyMem(addr(buf[0]), ms.data, ms.size)
|
copyMem(addr(result[0]), ms.data, ms.size)
|
||||||
result = buf
|
|
||||||
|
|
||||||
iterator memSlices*(mfile: MemFile, delim='\l', eat='\r'): MemSlice {.inline.} =
|
iterator memSlices*(mfile: MemFile, delim='\l', eat='\r'): MemSlice {.inline.} =
|
||||||
## Iterates over [optional `eat`] `delim`-delimited slices in MemFile `mfile`.
|
## Iterates over [optional `eat`] `delim`-delimited slices in MemFile `mfile`.
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue