[Issue 12060] Add ability to use dynamic array for `std.digest.*` as return type for hash

via Digitalmars-d-bugs digitalmars-d-bugs at puremagic.com
Sun Jul 19 06:42:55 PDT 2015


https://issues.dlang.org/show_bug.cgi?id=12060

Johannes Pfau <johannespfau at gmail.com> changed:

           What    |Removed                     |Added
----------------------------------------------------------------------------
                 CC|                            |johannespfau at gmail.com

--- Comment #1 from Johannes Pfau <johannespfau at gmail.com> ---
>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.

--


More information about the Digitalmars-d-bugs mailing list