Prechádzať zdrojové kódy

bin/darkirc/irc: (clippy chore) replace as_bytes().len() with len() since it returns the bytes length on strings

skoupidi 1 rok pred
rodič
commit
6f5dafad7a

+ 1 - 1
bin/darkirc/src/irc/client.rs

@@ -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.

+ 2 - 2
bin/darkirc/src/irc/command.rs

@@ -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,
@@ -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,