[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 10:44:01 PDT 2016


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

--- Comment #8 from hsteoh at quickfur.ath.cx ---
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? Of course, this doesn't work for
general input ranges (have to allocate somehow in that case), but conceivably
it could be done for ranges with hasSlicing?  Or, for forward ranges, use
.save. Obviously, this will depend on whether .save allocates, but then it's
the user's problem, not ours.

The advantage is that we don't have to allocate at all, at least in some cases.
The disadvantage is that you'll need to decode again every time grapheme
members are accessed. It may cause poor performance.

--


More information about the Digitalmars-d-bugs mailing list