about summary refs log tree commit diff stats
path: root/src/io
diff options
context:
space:
mode:
authorbptato <nincsnevem662@gmail.com>2023-09-24 01:08:30 +0200
committerbptato <nincsnevem662@gmail.com>2023-09-24 01:17:42 +0200
commite0745a3e88d737833c520ae363eaad9d43f1786d (patch)
treec51024dd741431b3674b3e685d473c52f1c28d9c /src/io
parentbe9ba2f95826227fd46fcc46c2ca1bb061acd41e (diff)
downloadchawan-e0745a3e88d737833c520ae363eaad9d43f1786d.tar.gz
regex: copy after compiling
Instead of the broken attempt at making regexes zero-copy (it copied
anyway), copy once and forget about it.

(There have been way too many problems with the destructor approach,
including the latest one where the GC would happily zero out our
regexes if they were in a sequence.

Maybe we can make this work once we switched to ORC. For now, it's
not worth the trouble.)
Diffstat (limited to 'src/io')
-rw-r--r--src/io/serialize.nim25
1 files changed, 0 insertions, 25 deletions
diff --git a/src/io/serialize.nim b/src/io/serialize.nim
index 6994b042..d2e83524 100644
--- a/src/io/serialize.nim
+++ b/src/io/serialize.nim
@@ -5,7 +5,6 @@ import sets
 import streams
 import tables
 
-import js/regex
 import loader/request
 import types/blob
 import types/buffersource
@@ -73,10 +72,6 @@ proc swrite*[T, E](stream: Stream, o: Result[T, E])
 proc sread*[T, E](stream: Stream, o: var Result[T, E])
 func slen*[T, E](o: Result[T, E]): int
 
-proc swrite*(stream: Stream, regex: Regex)
-proc sread*(stream: Stream, regex: var Regex)
-func slen*(regex: Regex): int
-
 proc swrite*(stream: Stream, source: BufferSource)
 proc sread*(stream: Stream, source: var BufferSource)
 func slen*(source: BufferSource): int
@@ -389,26 +384,6 @@ func slen*[T, E](o: Result[T, E]): int =
     when not (E is void):
       result += slen(o.error)
 
-proc swrite*(stream: Stream, regex: Regex) =
-  stream.swrite(regex.plen)
-  stream.writeData(regex.bytecode, regex.plen)
-  stream.swrite(regex.buf)
-
-proc sread*(stream: Stream, regex: var Regex) =
-  assert regex.bytecode == nil
-  stream.sread(regex.plen)
-  regex.bytecode = cast[ptr uint8](alloc(regex.plen))
-  regex.clone = true
-  let l = stream.readData(regex.bytecode, regex.plen)
-  stream.sread(regex.buf)
-  if l != regex.plen:
-    `=destroy`(regex)
-
-func slen*(regex: Regex): int =
-  result += slen(regex.plen)
-  result += regex.plen
-  result += slen(regex.buf)
-
 proc swrite*(stream: Stream, source: BufferSource) =
   stream.swrite(source.t)
   case source.t