Use copy_from_slice instead of copy_memory #173

Closed
opened 2018-03-18 06:23:43 -05:00 by nox · 4 comments
nox commented 2018-03-18 06:23:43 -05:00 (Migrated from github.com)

There is no need to write our own copy_memory method, we can just use <[_]>::copy_from_slice which can be implemented in a more optimised way by the standard library.

There is no need to write our own `copy_memory` method, we can just use [`<[_]>::copy_from_slice`](https://doc.rust-lang.org/std/primitive.slice.html#method.copy_from_slice) which can be implemented in a more optimised way by the standard library.
kinggoesgaming commented 2018-03-18 17:46:39 -05:00 (Migrated from github.com)

So testing it, it seems our copy_memory function is faster than builtin <[_]>::copy_from_slice

Results from cargo +nightly bench --all-features:
https://gist.github.com/kinggoesgaming/25a5240ea8741524cdc8dc588ed6b046

Edit: Changes made here for reference https://github.com/uuid-rs/uuid/compare/copy-from-slice

So testing it, it seems our `copy_memory` function is faster than builtin `<[_]>::copy_from_slice` Results from `cargo +nightly bench --all-features`: https://gist.github.com/kinggoesgaming/25a5240ea8741524cdc8dc588ed6b046 Edit: Changes made here for reference https://github.com/uuid-rs/uuid/compare/copy-from-slice
KodrAus commented 2018-03-18 18:09:28 -05:00 (Migrated from github.com)

Hmm, I think this might be a bit of test noise, it looks like both methods are emitting the same assembly.

Hmm, I think this might be a bit of test noise, it looks like both methods are emitting the same assembly.
kinggoesgaming commented 2018-03-18 20:31:52 -05:00 (Migrated from github.com)

Seemingly it was test noise or just my computer being funny... it is generally faster, but anywhere it is slow, its only slowly by 1-2 nanosecs

Seemingly it was test noise or just my computer being funny... it is generally faster, but anywhere it is slow, its only slowly by 1-2 nanosecs
kinggoesgaming commented 2018-03-19 11:10:13 -05:00 (Migrated from github.com)
#175
Sign in to join this conversation.
No milestone
No assignees
1 participant
Notifications
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set

Reference
gh-uuid-rs/uuid#173
No description provided.