change: Do not dereference str whenever possible

This commit is contained in:
SinTan1729
2023-05-23 18:03:27 -05:00
parent 7b59a9aa5c
commit a4e7c6b444
2 changed files with 4 additions and 4 deletions

View File

@@ -28,14 +28,14 @@ pub fn add_link(req: String, db: &Connection) -> (bool, String) {
let mut shortlink;
if chunks.len() > 1 {
shortlink = chunks[1].to_string().to_lowercase();
if shortlink == *"" {
if shortlink.is_empty() {
shortlink = random_name();
}
} else {
shortlink = random_name();
}
if validate_link(shortlink.as_str()) && get_longurl(shortlink.clone(), db) == *"" {
if validate_link(shortlink.as_str()) && get_longurl(shortlink.clone(), db).is_empty() {
(
database::add_link(shortlink.clone(), longlink, db),
shortlink,