mirror of
https://github.com/nim-lang/Nim.git
synced 2026-01-04 12:07:51 +00:00
Save some alloc on base64 using encodeSize (#16465)
This commit is contained in:
@@ -193,6 +193,7 @@ proc encodeMime*(s: string, lineLen = 75, newLine = "\r\n"): string =
|
||||
## * `decode proc<#decode,string>`_ for decoding a string
|
||||
runnableExamples:
|
||||
assert encodeMime("Hello World", 4, "\n") == "SGVs\nbG8g\nV29y\nbGQ="
|
||||
result = newStringOfCap(encodeSize(s.len))
|
||||
for i, c in encode(s):
|
||||
if i != 0 and (i mod lineLen == 0):
|
||||
result.add(newLine)
|
||||
|
||||
Reference in New Issue
Block a user