Templatize _d_arraysetcapacity hook#21143
Conversation
|
Thanks for your pull request and interest in making D better, @Albert24GG! 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 run digger -- build "master + dmd#21143" |
teodutu
left a comment
There was a problem hiding this comment.
Nice work overall! The failing tests seem unrelated to your work: a timeout and two file-related errors.
The previous implementation included a more convoluted way of achieving the same goal. `is(typeof(arr[0].__xpostblit()))` was replaced by `__traits(compiles, arr[0].__xpostblit)` and `is(immutable T == immutable U, U)` with `alias Unqual_T = Unqual!T`
teodutu
left a comment
There was a problem hiding this comment.
I only made some spacing suggestions. Otherwise this looks good. Thanks!
This ensures that the TypeInfo will be computed only once, during the first call made to the templated function instance.
|
@teodutu let me know when this is good to go |
It's OK now. The tests are failing because installing the host DMD returns 403, which is unrelated. |
|
@Albert24GG see this comment and create a PR with a changelog entry for this hook as well. Let's keep this in mind for the future. [1] #21151 (comment) |
|
This pull request introduced a regression: |
This replaces the
_d_arraysetcapacityruntime hook fromrt/lifetime.dwith a templated version, now located incore/internal/array/capacity.d.All the TypeInfo instances have been eliminated, except for the one pass as an argument to
GC.malloc.The only walkaround that I needed to do is to use a "fake" pure & nothrow wrapper over the templated hook, since the
reserveandcapacityfunctions both are pure & nothrow, but the__doPostblitfunction can sometimes invoke impure postblits, depending on the type T passed. If you have any suggestions regarding this issue, please let me know!