Skip to content

Commit 829057d

Browse files
committed
release: 0.5.3
2 parents f641a25 + 74be1ca commit 829057d

File tree

7 files changed

+111
-55
lines changed

7 files changed

+111
-55
lines changed

CHANGELOG.md

+12
Original file line numberDiff line numberDiff line change
@@ -2,6 +2,18 @@
22

33

44

5+
## [0.5.3](https://github.com/Blobfolio/cdtoc/releases/tag/v0.5.3) - 2024-11-28
6+
7+
### Changed
8+
9+
* Bump `brunch` to `0.7` (dev)
10+
* Bump `dactyl` to `0.8`
11+
* Bump `trimothy` to `0.6`
12+
* Reduce intermediary allocations for AccurateRip::to_string, ::checksum_url
13+
* Miscellaneous code changes and lints
14+
15+
16+
517
## [0.5.2](https://github.com/Blobfolio/cdtoc/releases/tag/v0.5.2) - 2024-11-07
618

719
### Changed

CREDITS.md

+38-31
Original file line numberDiff line numberDiff line change
@@ -1,34 +1,41 @@
11
# Project Dependencies
22
Package: cdtoc
3-
Version: 0.5.2
4-
Generated: 2024-11-08 06:38:45 UTC
3+
Version: 0.5.3
4+
Generated: 2024-11-28 19:27:46 UTC
55

6-
| Package | Version | Author(s) | License | Context |
7-
| ---- | ---- | ---- | ---- | ---- |
8-
| [dactyl](https://github.com/Blobfolio/dactyl) | 0.7.4 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | |
9-
| [faster-hex](https://github.com/NervosFoundation/faster-hex) | 0.10.0 | [zhangsoledad](mailto:787953403@qq.com) | MIT | |
10-
| [trimothy](https://github.com/Blobfolio/trimothy) | 0.3.1 | [Blobfolio, LLC.](mailto:hello@blobfolio.com) | WTFPL | |
11-
| [block-buffer](https://github.com/RustCrypto/utils) | 0.10.4 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
12-
| [byteorder](https://github.com/BurntSushi/byteorder) | 1.5.0 | [Andrew Gallant](mailto:jamslam@gmail.com) | Unlicense OR MIT | target-specific |
13-
| [cc](https://github.com/rust-lang/cc-rs) | 1.1.36 | [Alex Crichton](mailto:alex@alexcrichton.com) | MIT OR Apache-2.0 | optional, build, target-specific |
14-
| [cfg-if](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:alex@alexcrichton.com) | MIT OR Apache-2.0 | optional |
15-
| [cpufeatures](https://github.com/RustCrypto/utils) | 0.2.14 | RustCrypto Developers | MIT OR Apache-2.0 | optional, target-specific |
16-
| [crypto-common](https://github.com/RustCrypto/traits) | 0.1.6 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
17-
| [digest](https://github.com/RustCrypto/traits) | 0.10.7 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
18-
| [generic-array](https://github.com/fizyk20/generic-array.git) | 0.14.7 | [Bartłomiej Kamiński](mailto:fizyk20@gmail.com) and [Aaron Trent](mailto:novacrazy@gmail.com) | MIT | optional |
19-
| [hash32](https://github.com/japaric/hash32) | 0.3.1 | [Jorge Aparicio](mailto:jorge@japaric.io) | MIT OR Apache-2.0 | target-specific |
20-
| [heapless](https://github.com/rust-embedded/heapless) | 0.8.0 | [Jorge Aparicio](mailto:jorge@japaric.io), [Per Lindgren](mailto:per.lindgren@ltu.se), and [Emil Fresk](mailto:emil.fresk@gmail.com) | MIT OR Apache-2.0 | target-specific |
21-
| [itoa](https://github.com/dtolnay/itoa) | 1.0.11 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 | optional |
22-
| [libc](https://github.com/rust-lang/libc) | 0.2.162 | The Rust Project Developers | MIT OR Apache-2.0 | optional, target-specific |
23-
| [proc-macro2](https://github.com/dtolnay/proc-macro2) | 1.0.89 | [David Tolnay](mailto:dtolnay@gmail.com) and [Alex Crichton](mailto:alex@alexcrichton.com) | MIT OR Apache-2.0 | optional, build, target-specific |
24-
| [quote](https://github.com/dtolnay/quote) | 1.0.37 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 | optional, build, target-specific |
25-
| [serde](https://github.com/serde-rs/serde) | 1.0.214 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 | optional |
26-
| [serde_derive](https://github.com/serde-rs/serde) | 1.0.214 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 | optional |
27-
| [sha1](https://github.com/RustCrypto/hashes) | 0.10.6 | RustCrypto Developers | MIT OR Apache-2.0 | optional |
28-
| [sha1-asm](https://github.com/RustCrypto/asm-hashes) | 0.5.3 | RustCrypto Developers | MIT | optional, target-specific |
29-
| [shlex](https://github.com/comex/rust-shlex) | 1.3.0 | [comex](mailto:comexk@gmail.com), [Fenhl](mailto:fenhl@fenhl.net), [Adrian Taylor](mailto:adetaylor@chromium.org), [Alex Touchet](mailto:alextouchet@outlook.com), [Daniel Parks](mailto:dp+git@oxidized.org), and [Garrett Berg](mailto:googberg@gmail.com) | MIT OR Apache-2.0 | optional, build, target-specific |
30-
| [stable_deref_trait](https://github.com/storyyeller/stable_deref_trait) | 1.2.0 | [Robert Grosse](mailto:n210241048576@gmail.com) | MIT OR Apache-2.0 | target-specific |
31-
| [syn](https://github.com/dtolnay/syn) | 2.0.87 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 | optional, build, target-specific |
32-
| [typenum](https://github.com/paholg/typenum) | 1.17.0 | [Paho Lurie-Gregg](mailto:paho@paholg.com) and [Andre Bogus](mailto:bogusandre@gmail.com) | MIT OR Apache-2.0 | optional |
33-
| [unicode-ident](https://github.com/dtolnay/unicode-ident) | 1.0.13 | [David Tolnay](mailto:dtolnay@gmail.com) | (MIT OR Apache-2.0) AND Unicode-DFS-2016 | optional, build, target-specific |
34-
| [version_check](https://github.com/SergioBenitez/version_check) | 0.9.5 | [Sergio Benitez](mailto:sb@sergio.bz) | MIT OR Apache-2.0 | optional, build |
6+
| Package | Version | Author(s) | License |
7+
| ---- | ---- | ---- | ---- |
8+
| [**dactyl**](https://github.com/Blobfolio/dactyl) | 0.8.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
9+
| [**faster-hex**](https://github.com/NervosFoundation/faster-hex) | 0.10.0 | [zhangsoledad](mailto:787953403@qq.com) | MIT |
10+
| [**trimothy**](https://github.com/Blobfolio/trimothy) | 0.6.0 | [Josh Stoik](mailto:josh@blobfolio.com) | WTFPL |
11+
| [_block-buffer_](https://github.com/RustCrypto/utils) | 0.10.4 | RustCrypto Developers | MIT OR Apache-2.0 |
12+
| [_byteorder_](https://github.com/BurntSushi/byteorder) | 1.5.0 | [Andrew Gallant](mailto:jamslam@gmail.com) | Unlicense OR MIT |
13+
| [_cc_](https://github.com/rust-lang/cc-rs) ⚒️ | 1.2.1 | [Alex Crichton](mailto:alex@alexcrichton.com) | MIT OR Apache-2.0 |
14+
| [_cfg-if_](https://github.com/alexcrichton/cfg-if) | 1.0.0 | [Alex Crichton](mailto:alex@alexcrichton.com) | MIT OR Apache-2.0 |
15+
| [_cpufeatures_](https://github.com/RustCrypto/utils) | 0.2.16 | RustCrypto Developers | MIT OR Apache-2.0 |
16+
| [_crypto-common_](https://github.com/RustCrypto/traits) | 0.1.6 | RustCrypto Developers | MIT OR Apache-2.0 |
17+
| [_digest_](https://github.com/RustCrypto/traits) | 0.10.7 | RustCrypto Developers | MIT OR Apache-2.0 |
18+
| [_generic-array_](https://github.com/fizyk20/generic-array.git) | 0.14.7 | [Bartłomiej Kamiński](mailto:fizyk20@gmail.com) and [Aaron Trent](mailto:novacrazy@gmail.com) | MIT |
19+
| [_hash32_](https://github.com/japaric/hash32) | 0.3.1 | [Jorge Aparicio](mailto:jorge@japaric.io) | MIT OR Apache-2.0 |
20+
| [_heapless_](https://github.com/rust-embedded/heapless) | 0.8.0 | [Jorge Aparicio](mailto:jorge@japaric.io), [Per Lindgren](mailto:per.lindgren@ltu.se), and [Emil Fresk](mailto:emil.fresk@gmail.com) | MIT OR Apache-2.0 |
21+
| [**_itoa_**](https://github.com/dtolnay/itoa) | 1.0.14 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
22+
| [_libc_](https://github.com/rust-lang/libc) | 0.2.166 | The Rust Project Developers | MIT OR Apache-2.0 |
23+
| [_proc-macro2_](https://github.com/dtolnay/proc-macro2) ⚒️ | 1.0.92 | [David Tolnay](mailto:dtolnay@gmail.com) and [Alex Crichton](mailto:alex@alexcrichton.com) | MIT OR Apache-2.0 |
24+
| [_quote_](https://github.com/dtolnay/quote) ⚒️ | 1.0.37 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
25+
| [**_serde_**](https://github.com/serde-rs/serde) | 1.0.215 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
26+
| [_serde_derive_](https://github.com/serde-rs/serde) | 1.0.215 | [Erick Tryzelaar](mailto:erick.tryzelaar@gmail.com) and [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
27+
| [**_sha1_**](https://github.com/RustCrypto/hashes) | 0.10.6 | RustCrypto Developers | MIT OR Apache-2.0 |
28+
| [_sha1-asm_](https://github.com/RustCrypto/asm-hashes) | 0.5.3 | RustCrypto Developers | MIT |
29+
| [_shlex_](https://github.com/comex/rust-shlex) ⚒️ | 1.3.0 | [comex](mailto:comexk@gmail.com), [Fenhl](mailto:fenhl@fenhl.net), [Adrian Taylor](mailto:adetaylor@chromium.org), [Alex Touchet](mailto:alextouchet@outlook.com), [Daniel Parks](mailto:dp+git@oxidized.org), and [Garrett Berg](mailto:googberg@gmail.com) | MIT OR Apache-2.0 |
30+
| [_stable_deref_trait_](https://github.com/storyyeller/stable_deref_trait) | 1.2.0 | [Robert Grosse](mailto:n210241048576@gmail.com) | MIT OR Apache-2.0 |
31+
| [_syn_](https://github.com/dtolnay/syn) ⚒️ | 2.0.89 | [David Tolnay](mailto:dtolnay@gmail.com) | MIT OR Apache-2.0 |
32+
| [_typenum_](https://github.com/paholg/typenum) | 1.17.0 | [Paho Lurie-Gregg](mailto:paho@paholg.com) and [Andre Bogus](mailto:bogusandre@gmail.com) | MIT OR Apache-2.0 |
33+
| [_unicode-ident_](https://github.com/dtolnay/unicode-ident) ⚒️ | 1.0.14 | [David Tolnay](mailto:dtolnay@gmail.com) | (MIT OR Apache-2.0) AND Unicode-3.0 |
34+
| [_version_check_](https://github.com/SergioBenitez/version_check) ⚒️ | 0.9.5 | [Sergio Benitez](mailto:sb@sergio.bz) | MIT OR Apache-2.0 |
35+
36+
### Legend
37+
38+
* **Direct Dependency**
39+
* Child Dependency
40+
* _Optional Dependency_
41+
* ⚒️ Build-Only

Cargo.toml

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
[package]
22
name = "cdtoc"
3-
version = "0.5.2"
3+
version = "0.5.3"
44
authors = ["Josh Stoik <josh@blobfolio.com>"]
55
edition = "2021"
66
rust-version = "1.81"
@@ -27,12 +27,12 @@ features = [ "accuraterip", "cddb", "ctdb", "musicbrainz", "serde" ]
2727
default-target = "x86_64-unknown-linux-gnu"
2828

2929
[dev-dependencies]
30-
brunch = "0.6.*"
30+
brunch = "0.7.*"
3131
serde_json = "1.0.*"
3232

3333
[dependencies]
34-
dactyl = "0.7.*"
35-
trimothy = "0.3.*"
34+
dactyl = "0.8.*"
35+
trimothy = "0.6.*"
3636

3737
[dependencies.faster-hex]
3838
version = "0.10.*"

src/accuraterip.rs

+48-15
Original file line numberDiff line numberDiff line change
@@ -80,9 +80,11 @@ impl From<AccurateRip> for [u8; 13] {
8080
}
8181

8282
impl fmt::Display for AccurateRip {
83-
#[inline]
8483
fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result {
85-
f.pad(&self.pretty_print())
84+
let disc_id = self.encode();
85+
std::str::from_utf8(disc_id.as_slice())
86+
.map_err(|_| fmt::Error)
87+
.and_then(|s| f.pad(s))
8688
}
8789
}
8890

@@ -158,6 +160,7 @@ impl AccurateRip {
158160
/// ```
159161
pub const fn audio_len(&self) -> u8 { self.0[0] }
160162

163+
#[expect(unsafe_code, reason = "For performance.")]
161164
#[must_use]
162165
/// # AccurateRip Checksum URL.
163166
///
@@ -180,18 +183,22 @@ impl AccurateRip {
180183
/// );
181184
/// ```
182185
pub fn checksum_url(&self) -> String {
183-
let disc_id = self.to_string();
184-
[
185-
"http://www.accuraterip.com/accuraterip/",
186-
&disc_id[11..12],
187-
"/",
188-
&disc_id[10..11],
189-
"/",
190-
&disc_id[9..10],
191-
"/dBAR-",
192-
&disc_id,
193-
".bin",
194-
].concat()
186+
// First things first, build the disc ID.
187+
let disc_id = self.encode();
188+
debug_assert!(disc_id.is_ascii(), "Bug: AccurateRip ID is not ASCII?!");
189+
190+
let mut out = String::with_capacity(84);
191+
out.push_str("http://www.accuraterip.com/accuraterip/");
192+
out.push(char::from(disc_id[11]));
193+
out.push('/');
194+
out.push(char::from(disc_id[10]));
195+
out.push('/');
196+
out.push(char::from(disc_id[9]));
197+
out.push_str("/dBAR-");
198+
// Safety: all bytes are ASCII.
199+
out.push_str(unsafe { std::str::from_utf8_unchecked(disc_id.as_slice()) });
200+
out.push_str(".bin");
201+
out
195202
}
196203

197204
#[must_use]
@@ -436,13 +443,39 @@ impl AccurateRip {
436443
faster_hex::hex_encode_fallback(&[self.0[8], self.0[7], self.0[6], self.0[5]], &mut out[13..21]);
437444
faster_hex::hex_encode_fallback(&[self.0[12], self.0[11], self.0[10], self.0[9]], &mut out[22..]);
438445

439-
debug_assert!(out.is_ascii(), "Bug: AccurateRip checksum is not ASCII?!");
446+
debug_assert!(out.is_ascii(), "Bug: AccurateRip ID is not ASCII?!");
440447

441448
// Safety: all bytes are ASCII.
442449
unsafe { String::from_utf8_unchecked(out) }
443450
}
444451
}
445452

453+
impl AccurateRip {
454+
#[inline]
455+
/// # Encode to Buffer.
456+
///
457+
/// Format the AccurateRip ID for display, returning the bytes as a
458+
/// fixed-length array.
459+
fn encode(&self) -> [u8; 30] {
460+
let mut disc_id: [u8; 30] = [
461+
b'0', b'0', b'0',
462+
b'-', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0',
463+
b'-', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0',
464+
b'-', b'0', b'0', b'0', b'0', b'0', b'0', b'0', b'0',
465+
];
466+
467+
// Length.
468+
disc_id[..3].copy_from_slice(dactyl::NiceU8::from(self.0[0]).as_bytes3());
469+
470+
// ID Parts.
471+
faster_hex::hex_encode_fallback(&[self.0[4], self.0[3], self.0[2], self.0[1]], &mut disc_id[4..12]);
472+
faster_hex::hex_encode_fallback(&[self.0[8], self.0[7], self.0[6], self.0[5]], &mut disc_id[13..21]);
473+
faster_hex::hex_encode_fallback(&[self.0[12], self.0[11], self.0[10], self.0[9]], &mut disc_id[22..]);
474+
475+
disc_id
476+
}
477+
}
478+
446479

447480

448481
impl Toc {

src/lib.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -246,7 +246,7 @@ impl fmt::Display for Toc {
246246
($v:expr) => (
247247
faster_hex::hex_encode_fallback($v.to_be_bytes().as_slice(), &mut buf);
248248
out.push(b'+');
249-
out.extend_from_slice(buf.trim_start_matches(|b| b == b'0'));
249+
out.extend_from_slice(buf.trim_start_matches(b'0'));
250250
);
251251
}
252252

@@ -267,7 +267,7 @@ impl fmt::Display for Toc {
267267
faster_hex::hex_encode_fallback(self.data.to_be_bytes().as_slice(), &mut buf);
268268
out.push(b'+');
269269
out.push(b'X');
270-
out.extend_from_slice(buf.trim_start_matches(|b| b == b'0'));
270+
out.extend_from_slice(buf.trim_start_matches(b'0'));
271271
},
272272
}
273273

src/serde.rs

+1-1
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ impl<'de> Deserialize<'de> for TrackPosition {
191191
/// # Visitor Instance.
192192
struct Visitor;
193193

194-
impl<'de> de::Visitor<'de> for Visitor {
194+
impl de::Visitor<'_> for Visitor {
195195
type Value = TrackPosition;
196196

197197
fn expecting(&self, f: &mut fmt::Formatter) -> fmt::Result {

src/time.rs

+6-2
Original file line numberDiff line numberDiff line change
@@ -459,14 +459,18 @@ impl Duration {
459459
pub fn to_string_pretty(self) -> String {
460460
let (d, h, m, s, f) = self.dhmsf();
461461
let mut parts: Vec<String> = Vec::new();
462-
if d != 0 { parts.push(d.nice_inflect("day", "days")); }
462+
463+
// Days work the same way as the other parts, but have a different
464+
// integer type.
465+
if d != 0 { parts.push(d.nice_inflect("day", "days").to_string()); }
466+
463467
for (num, single, plural) in [
464468
(h, "hour", "hours"),
465469
(m, "minute", "minutes"),
466470
(s, "second", "seconds"),
467471
(f, "frame", "frames"),
468472
] {
469-
if num != 0 { parts.push(num.nice_inflect(single, plural)); }
473+
if num != 0 { parts.push(num.nice_inflect(single, plural).to_string()); }
470474
}
471475

472476
match parts.len() {

0 commit comments

Comments
 (0)