-
Notifications
You must be signed in to change notification settings - Fork 2
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
2023: Add performance hack for day 3
Not a good idea for all kinds of strings.
- Loading branch information
Showing
3 changed files
with
8 additions
and
1 deletion.
There are no files selected for viewing
This file contains 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
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,5 +1,7 @@ | ||
mod days; | ||
mod input; | ||
mod strings; | ||
|
||
pub use days::DAYS; | ||
pub use input::read_input; | ||
pub use strings::char_at; |
This file contains 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
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
#[inline(always)] | ||
pub fn char_at(str: &str, index: usize) -> char { | ||
// Not a good idea for all kinds of strings. | ||
*(&str[index..index + 1].chars().nth(0).unwrap()) | ||
} |