From e0745a3e88d737833c520ae363eaad9d43f1786d Mon Sep 17 00:00:00 2001 From: bptato Date: Sun, 24 Sep 2023 01:08:30 +0200 Subject: 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.) --- src/io/serialize.nim | 25 ------------------------- 1 file changed, 25 deletions(-) (limited to 'src/io') 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 -- cgit 1.4.1-2-gfad0 t' value='search'/>
path: root/lib/Crater/Service.rakumod
blob: 657d77b828c3e7cb89586d9e23491120dc9bab84 (plain) (blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53