Use CompactString::const_new when possible

Signed-off-by: Jiahao XU <Jiahao_XU@outlook.com>
This commit is contained in:
Jiahao XU 2024-07-12 23:52:47 +10:00
parent 2bd9c1efee
commit b8539071cd
No known key found for this signature in database
GPG key ID: 76D1E687CA3C4928
3 changed files with 5 additions and 5 deletions

View file

@ -96,10 +96,10 @@ pub(super) fn crate_prefix_components(
match (chars.next(), chars.next(), chars.next(), chars.next()) {
(None, None, None, None) => Err(RegistryError::NotFound(crate_name.into())),
(Some(_), None, None, None) => Ok((CompactString::new("1"), None)),
(Some(_), Some(_), None, None) => Ok((CompactString::new("2"), None)),
(Some(_), None, None, None) => Ok((CompactString::const_new("1"), None)),
(Some(_), Some(_), None, None) => Ok((CompactString::const_new("2"), None)),
(Some(ch), Some(_), Some(_), None) => Ok((
CompactString::new("3"),
CompactString::const_new("3"),
Some(ch.to_lowercase().to_compact_string()),
)),
(Some(a), Some(b), Some(c), Some(d)) => Ok((