Bug 12060 – Add ability to use dynamic array for `std.digest.*` as return type for hash

Status
RESOLVED
Resolution
WONTFIX
Severity
enhancement
Priority
P2
Component
phobos
Product
D
Version
D2
Platform
All
OS
All
Creation time
2014-02-02T03:40:00Z
Last change time
2016-03-16T06:47:08Z
Assigned to
nobody
Creator
ilya-stromberg-2009

Comments

Comment #0 by ilya-stromberg-2009 — 2014-02-02T03:40:03Z
It can be useful for many cases. For example, it allows to avoid unnecessary hash copy for Template API. Also, it can help to avoid unnecessary memory allocation for OOP API. As little bonus, it lets to use `std.allocator` for memory allocation.
Comment #1 by johannespfau — 2015-07-19T13:42:55Z
>return type for hash return type for which function exactly? If you mean the struct finish method: I don't think that's useful. The template digest API is designed in a way to completely avoid memory allocation. You can simply use .idup to get an GC allocated array and we should probably have an .idup(allocator) function or similar for std.allocator. >avoid unnecessary hash copy for Template API I doubt that avoiding a copy in the template API would get some real speed benefits (remember that a ubyte[] slice is already 16 bytes on 64 bit systems, just as big as the complete MD5 hash value). Compilers likely optimize these copies. I think we need some benchmarks which show that copies are a problem here. >it can help to avoid unnecessary memory allocation for OOP API You'd only move the allocation point from OOP API to template API.
Comment #2 by johannespfau — 2016-03-16T06:47:08Z
Please reopen if further discussion is necessary.