New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Make create zero out the new buffer #102
Conversation
let buffer = Bigarray.(Array1.create char c_layout len) in | ||
{ buffer ; len ; off = 0 } | ||
|
||
let create len = | ||
let t = create_unsafe len in | ||
Bigarray.Array1.fill t.buffer (Char.chr 0); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
shouldn't we reuse the memset
we define ~110 lines below?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there any benefit? I guess memset
is only needed if you want to fill a sub-region of an array (fill
can only fill the whole thing, but that's what we want here).
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
consistency is my argument (I've to keep less symbols in my head when reading the code)
The new `create_unsafe` function can be used if you want to trade safety for speed. Fixes mirage#30
OK, it uses |
imho good to go (apart from a missing changes entry)! thanks! |
I'm yomimono and I approve this PR. |
there's no need to allocate and fill with zero just to blit afterwards. this is a performance regression which was introduced in mirage#102 (May 2016), when `create` changed its semantics.
The API should be safe by default. The new
create_unsafe
function can be used if you want to trade safety for speed.Fixes #30
See also: mirage/mirage-tcpip#204