List of Phobos functions that allocate memory?
Jonathan M Davis
jmdavisProg at gmx.com
Sat Feb 8 22:03:54 PST 2014
On Saturday, February 08, 2014 14:13:04 Walter Bright wrote:
> On 2/7/2014 11:53 AM, Jonathan M Davis wrote:
> > or to avoid allocating them
>
> Grep for 'throw' in std.datetime shows that every throw is actually:
>
> throw new ...
>
> and an example:
>
> throw new DateTimeException("SYSTEMTIME cannot hold dates prior to the
> year 1601.");
>
> There is no requirement that the new is done there. You can preallocate the
> DateTimeException statically, and simply keep rethrowing the same exception
> instance.
>
> I.e. the allocation issue is a coding style issue, not a language problem.
Of course allocation is not a language issue. The question is whether (and
how) we can change our approach to allocating exceptions in order to reduce
their cost. And that's a change in how we approach them, not a change in the
language itself. It might require some changes in druntime to better deal with
other allocation schemes (particularly with how that affects exception
chaining), but it's not a language issue.
And in general, I would expect that any speed-ups that we could attain with
regards to actually throwing an exception would be in druntime's
implementation rather than anything in the language itself. Any improvements
there could then be combined with any improvements we could make to our
approach to allocating exceptions (and for better or worse - probably worse -
the normal approach at this point is to allocate a new exception when
throwing).
- Jonathan M Davis
More information about the Digitalmars-d
mailing list