Bug 18223 – std.experimental.allocator uninitializedFillDefault could use memset

Status
RESOLVED
Resolution
FIXED
Severity
enhancement
Priority
P1
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2018-01-11T06:32:35Z
Last change time
2018-03-31T04:58:32Z
Assigned to
No Owner
Creator
Nathan S.

Comments

Comment #0 by n8sh.secondary — 2018-01-11T06:32:35Z
Current function in std.experimental.allocator.package: ``` private T[] uninitializedFillDefault(T)(T[] array) nothrow { T t = T.init; fillWithMemcpy(array, t); return array; } ``` When we can statically determine that the representation of T.init consists of nothing but zeroes we could instead use memset. char and wchar could also be special-cased.
Comment #1 by n8sh.secondary — 2018-02-05T20:27:22Z
Comment #2 by github-bugzilla — 2018-03-31T04:58:31Z
Commits pushed to master at https://github.com/dlang/phobos https://github.com/dlang/phobos/commit/8777cbf35505704bc2908baa4ae04d988f339bf8 Fix Issue 18223: use memset in uninitializedFillDefault(T[]) When we can statically determine that the representation of T.init consists of nothing but zeroes or nothing but ones we use memset. (The second case occurs for char and wchar.) https://github.com/dlang/phobos/commit/6797b52c0d99980b645bcbaf75c8bd6acf0b9613 Merge pull request #6024 from n8sh/uninitializedFillDefault-memset Fix Issue 18223: use memset in uninitializedFillDefault(T[]) merged-on-behalf-of: unknown