Draft
Conversation
eadwright
commented
Aug 20, 2023
| } | ||
| } | ||
|
|
||
| fn new_with_time(item: T, creation_time: SystemTime) -> Self { |
Author
There was a problem hiding this comment.
At one point I wanted to specify time in my tests, then I realised input order probably suffices.
eadwright
commented
Aug 20, 2023
| } | ||
| self.voices.insert(WithCreationTime::new(key), sink); | ||
| self.voices.get(&WithCreationTime::new(key)) | ||
| let w = WithCreationTime::new_with_time(key, time); |
Author
There was a problem hiding this comment.
I think the original code calling the constructor twice may be a bug? You may end up with different timestamps in each, and you want your map lookup to be based on the Key only I believe, not the time.
eadwright
commented
Aug 20, 2023
src/voices/voices2.rs
Outdated
| use rdev::Key; | ||
|
|
||
| fn get_ordinal(key: Key) -> u8 { | ||
| let ptr_to_option = (&key as *const Key) as *const u8; |
Author
There was a problem hiding this comment.
The underlying representation for an enum with under 256 variants starts with an ordinal byte, guaranteed. Get that number!
Author
|
Inspiring? |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
benchfor crude benchmarkingVoices, making it generic (needed in earlier testing, probably no longer needed). Note passing Key enums by value is cheap, we don't need references.Voices2is where the action isbench.rscontains the simple benchmark, for better or worseu128as there are fewer than 128 keys. If that were not the case it'll blow up.This code isn't polished and is meant to inspire ideas.
Note we can derive an enum ordinal using a crate, but
Keywas defined in a dependency so we can't, hence the hack with 🤭 unsafe.