diff options
author | bptato <nincsnevem662@gmail.com> | 2025-04-30 19:56:03 +0200 |
---|---|---|
committer | bptato <nincsnevem662@gmail.com> | 2025-04-30 19:56:03 +0200 |
commit | 7cd1207c86761e7c79b7be411002153d4eee855f (patch) | |
tree | d7f961d079366238ddd0d80e1e05f7a5edaf7f99 | |
parent | ef2034bf108d437e25eb125945f189c49a4cc296 (diff) | |
download | chawan-7cd1207c86761e7c79b7be411002153d4eee855f.tar.gz |
jsregex: remove use of newSeqUninitialized
It's fine to zero-fill this.
-rw-r--r-- | lib/monoucha0/monoucha/jsregex.nim | 9 |
1 files changed, 4 insertions, 5 deletions
diff --git a/lib/monoucha0/monoucha/jsregex.nim b/lib/monoucha0/monoucha/jsregex.nim index aa550949..249e32c5 100644 --- a/lib/monoucha0/monoucha/jsregex.nim +++ b/lib/monoucha0/monoucha/jsregex.nim @@ -38,13 +38,12 @@ proc compileRegex*(buf: string; flags: LREFlags = {}): Result[Regex, string] = errorMsg.setLen(i) return err(errorMsg) assert plen > 0 - var bcseq = newSeqUninitialized[uint8](plen) - copyMem(addr bcseq[0], bytecode, plen) - dealloc(bytecode) - var regex = Regex(bytecode: bcseq) + var regex = Regex(bytecode: newSeq[uint8](plen)) when defined(debug): regex.buf = buf - return ok(regex) + copyMem(addr regex.bytecode[0], bytecode, plen) + dealloc(bytecode) + return ok(move(regex)) proc exec*(regex: Regex; str: string; start = 0; length = -1; nocaps = false): RegexResult = |