Avoid using the GC (when active) in toCStringThen#9483
Avoid using the GC (when active) in toCStringThen#9483jacob-carlborg wants to merge 1 commit intodlang:masterfrom
Conversation
|
Thanks for your pull request and interest in making D better, @jacob-carlborg! We are looking forward to reviewing it, and you should be hearing from a maintainer soon.
Please see CONTRIBUTING.md for more information. If you have addressed all reviews or aren't sure how to proceed, don't hesitate to ping us with a simple comment. Bugzilla referencesYour PR doesn't reference any Bugzilla issue. If your PR contains non-trivial changes, please reference a Bugzilla issue or create a manual changelog. Testing this PR locallyIf you don't have a local development environment setup, you can use Digger to test this PR: dub fetch digger
dub run digger -- build "master + dmd#9483" |
By default `xmalloc` forwards to `malloc`. When using DMD as a library the GC is active and `xmalloc` forwards to the GC. Since the memory is always freed on return there's no reason to use the GC.
5aaf487 to
33da555
Compare
|
On Windows, GC.malloc/free is usually faster than C's malloc, so this would not really be an improvement. (Recent tests when using a disabled GC in dmd showed slightly better performance than the non-GC version at the cost of using a bit more memory). |
| Returns: | ||
| The return value of `T` | ||
| */ | ||
| auto toCStringThen(alias dg)(const(char)[] src) nothrow |
There was a problem hiding this comment.
My guess is that it should be inferred, and maybe @jacob-carlborg has a non-nothrow delegate.
However we don't have any place in DMD that use exceptions, and IIRC Walter is clearly against it, which is why this is here in the first place.
There was a problem hiding this comment.
Yeah the only reason I could see to remove it is if it were exposed in dmd as a library.
|
Ok, this seems pointless. |
By default
xmallocforwards tomalloc. When using DMD as a library the GC is active andxmallocforwards to the GC. Since the memory is always freed on return there's no reason to use the GC.