Skip to content

Commit

Permalink
bin/darkirc/irc: (clippy chore) replace as_bytes().len() with len() s…
Browse files Browse the repository at this point in the history
…ince it returns the bytes length on strings
  • Loading branch information
skoupidi committed Nov 12, 2024
1 parent 4074bac commit 6f5dafa
Show file tree
Hide file tree
Showing 2 changed files with 3 additions and 3 deletions.
2 changes: 1 addition & 1 deletion bin/darkirc/src/irc/client.rs
Original file line number Diff line number Diff line change
Expand Up @@ -250,7 +250,7 @@ impl Client {
// longer than our MAX_NICK_LEN, so in case it is garbled, it should be
// skipped by this code.
let have_channel = self.channels.read().await.contains(&privmsg.channel);
let msg_for_self = !privmsg.channel.starts_with('#') && privmsg.channel.as_bytes().len() <= MAX_NICK_LEN;
let msg_for_self = !privmsg.channel.starts_with('#') && privmsg.channel.len() <= MAX_NICK_LEN;

if have_channel || msg_for_self {
// Add the nickname to the list of nicks on the channel, if it's a channel.
Expand Down
4 changes: 2 additions & 2 deletions bin/darkirc/src/irc/command.rs
Original file line number Diff line number Diff line change
Expand Up @@ -281,7 +281,7 @@ impl Client {
channels.remove(list.as_str());

for channel in list.split(',') {
if !channel.starts_with('#') || channel.as_bytes().len() > MAX_NICK_LEN {
if !channel.starts_with('#') || channel.len() > MAX_NICK_LEN {
self.penalty.fetch_add(1, SeqCst);
return Ok(vec![ReplyType::Server((
ERR_NEEDMOREPARAMS,
Expand Down Expand Up @@ -518,7 +518,7 @@ impl Client {
}

// Disallow too long nicks
if nickname.as_bytes().len() > MAX_NICK_LEN {
if nickname.len() > MAX_NICK_LEN {
self.penalty.fetch_add(1, SeqCst);
return Ok(vec![ReplyType::Server((
ERR_ERRONEOUSNICKNAME,
Expand Down

0 comments on commit 6f5dafa

Please sign in to comment.