[Issue 13348] std.uni.Grapheme is impure due to using C malloc and friends

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Thu Jun 2 11:16:04 PDT 2016


https://issues.dlang.org/show_bug.cgi?id=13348

--- Comment #9 from Steven Schveighoffer <schveiguy at yahoo.com> ---
(In reply to Dmitry Olshansky from comment #7)
> Should I just use GC?

At this point, if we were to fix purity, I think this is the way to go. From
your comments in the code, you said that most of the time allocations will not
happen. I'm sure this varies with the language being processed, but it's
probably mostly true.

One other nice benefit about using the GC is you can remove the requirement to
copy the current grapheme if it's on the heap (and make that immutable also, so
Grapheme can be passed to another thread if the wrapped range allows it), and
copying the struct itself would be less expensive.

If we were to wait for pure-compatible reference counting to materialize, this
would be the ideal mechanism.

(In reply to hsteoh from comment #8)
> Here's a thought, I don't know how feasible it is, but what about using
> slices of the input string, and decode on demand?

Not a big fan of this idea. It puts extra demand on the wrapped range type
(must be sliceable or at least forward range), and might make things slower in
the case where the stack-allocated part of the union would be sufficient.

--


More information about the Digitalmars-d-bugs mailing list