digitalmars.D - Historic background of std.regex and BacktrackingMatcher
- Mai Lapyst (14/14) Oct 05 2023 I'm currently working through the dmd (and phobos for that
- user1234 (9/23) Oct 05 2023 Not a formal answers but two clues:
I'm currently working through the dmd (and phobos for that matter), and come across it's regex implementation. Here I found out it makes rather heavy usage of malloc / pureMalloc; on one side to allocate the Matcher implementation inside `GenericFactory`; on the other side in `BacktrackingMatcher` for memory of it's stack. Is there any historic reason why it dosnt uses more D-like features like `new` or dynamic arrays? It would certainly be safer to do so than using an untyped region of memory as stack-space. Also: if it needs "plain" memory; would this code be a good candidate to utilize `std.experimental.allocator` once released? Cheers, Mai
Oct 05 2023
On Thursday, 5 October 2023 at 13:36:10 UTC, Mai Lapyst wrote:I'm currently working through the dmd (and phobos for that matter), and come across it's regex implementation. Here I found out it makes rather heavy usage of malloc / pureMalloc; on one side to allocate the Matcher implementation inside `GenericFactory`; on the other side in `BacktrackingMatcher` for memory of it's stack. Is there any historic reason why it dosnt uses more D-like features like `new` or dynamic arrays? It would certainly be safer to do so than using an untyped region of memory as stack-space. Also: if it needs "plain" memory; would this code be a good candidate to utilize `std.experimental.allocator` once released? Cheers, MaiNot a formal answers but two clues: 1. when malloc is used in Phobos it's generally to bypass the GC 2. std.experimental.allocator was created way after std.regex Maybe std.regex will see your question and answer more accurately. He was active a few weeks ago, coincidentally to annouce he had started working on a better design for a D regex engine (https://forum.dlang.org/post/ctdkmvzttmpxwixkmvno forum.dlang.org)
Oct 05 2023