]> Untitled Git - lemmy.git/commitdiff
Remove unnecessary clone (#2874)
authorphankydn <42137630+phankydn@users.noreply.github.com>
Tue, 23 May 2023 23:00:19 +0000 (06:00 +0700)
committerGitHub <noreply@github.com>
Tue, 23 May 2023 23:00:19 +0000 (19:00 -0400)
Co-authored-by: KyP <phanky.vn@proton.me>
crates/api/src/comment/like.rs
crates/api/src/post/like.rs
crates/api_crud/src/comment/create.rs

index 3d216872a43a48b08284a072c16c2bfd8b9fddc4..6946b60c87aa68a1b5a6d39488dc9d52668eee8a 100644 (file)
@@ -72,8 +72,7 @@ impl Perform for CreateCommentLike {
     // Only add the like if the score isnt 0
     let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1);
     if do_add {
-      let like_form2 = like_form.clone();
-      CommentLike::like(context.pool(), &like_form2)
+      CommentLike::like(context.pool(), &like_form)
         .await
         .map_err(|e| LemmyError::from_error_message(e, "couldnt_like_comment"))?;
     }
index 53e6c13c6177c16d865f19e59f4ecded8a11284d..9fa480a5b5f509544667ad6a086cace08e1bf9eb 100644 (file)
@@ -60,8 +60,7 @@ impl Perform for CreatePostLike {
     // Only add the like if the score isnt 0
     let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1);
     if do_add {
-      let like_form2 = like_form.clone();
-      PostLike::like(context.pool(), &like_form2)
+      PostLike::like(context.pool(), &like_form)
         .await
         .map_err(|e| LemmyError::from_error_message(e, "couldnt_like_post"))?;
     }
index 511059ac98b25d09269f7ca7c0973f09c891f4ba..103c71ce64b3e3c8b08d8f3a366a199063788966 100644 (file)
@@ -107,9 +107,8 @@ impl PerformCrud for CreateComment {
       .build();
 
     // Create the comment
-    let comment_form2 = comment_form.clone();
     let parent_path = parent_opt.clone().map(|t| t.path);
-    let inserted_comment = Comment::create(context.pool(), &comment_form2, parent_path.as_ref())
+    let inserted_comment = Comment::create(context.pool(), &comment_form, parent_path.as_ref())
       .await
       .map_err(|e| LemmyError::from_error_message(e, "couldnt_create_comment"))?;