Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

refactor: fix clippy warnings (String::as_bytes) #1577

Merged
merged 1 commit into from
Nov 15, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion assembly/src/library/namespace.rs
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,7 @@ impl LibraryNamespace {
if matches!(source, Self::KERNEL_PATH | Self::EXEC_PATH | Self::ANON_PATH) {
return Ok(());
}
if source.as_bytes().len() > Self::MAX_LENGTH {
if source.len() > Self::MAX_LENGTH {
return Err(LibraryNamespaceError::Length);
}
if !source.starts_with(|c: char| c.is_ascii_lowercase() && c.is_ascii_alphabetic()) {
Expand Down
4 changes: 2 additions & 2 deletions assembly/src/library/path.rs
Original file line number Diff line number Diff line change
Expand Up @@ -192,8 +192,8 @@ impl LibraryPath {

/// Return the size in bytes of this path when displayed as a string
pub fn byte_len(&self) -> usize {
self.inner.components.iter().map(|c| c.as_bytes().len()).sum::<usize>()
+ self.inner.ns.as_str().as_bytes().len()
self.inner.components.iter().map(|c| c.len()).sum::<usize>()
+ self.inner.ns.as_str().len()
+ (self.inner.components.len() * 2)
}

Expand Down
2 changes: 1 addition & 1 deletion assembly/src/parser/scanner.rs
Original file line number Diff line number Diff line change
Expand Up @@ -41,7 +41,7 @@ pub struct Scanner<'input> {
impl<'input> Scanner<'input> {
/// Construct a new [Scanner] for the given `source`.
pub fn new(input: &'input str) -> Self {
let end = input.as_bytes().len();
let end = input.len();
assert!(end < u32::MAX as usize, "file too large");

let mut chars = input.char_indices().peekable();
Expand Down
2 changes: 1 addition & 1 deletion assembly/src/parser/token.rs
Original file line number Diff line number Diff line change
Expand Up @@ -860,7 +860,7 @@ impl<'input> Token<'input> {
// No match, it's an ident
None => Token::Ident(s),
// If the match is not exact, it's an ident
Some(matched) if matched.len() != s.as_bytes().len() => Token::Ident(s),
Some(matched) if matched.len() != s.len() => Token::Ident(s),
// Otherwise clone the Token corresponding to the keyword that was matched
Some(matched) => Self::KEYWORDS[matched.pattern().as_usize()].1.clone(),
}
Expand Down
Loading