Remove unnecessary clone (#2874)

Co-authored-by: KyP <phanky.vn@proton.me>
This commit is contained in:
phankydn 2023-05-24 06:00:19 +07:00 committed by GitHub
parent 82d93da26b
commit 4a70502007
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 3 additions and 6 deletions

View file

@ -72,8 +72,7 @@ impl Perform for CreateCommentLike {
// Only add the like if the score isnt 0 // Only add the like if the score isnt 0
let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1); let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1);
if do_add { if do_add {
let like_form2 = like_form.clone(); CommentLike::like(context.pool(), &like_form)
CommentLike::like(context.pool(), &like_form2)
.await .await
.map_err(|e| LemmyError::from_error_message(e, "couldnt_like_comment"))?; .map_err(|e| LemmyError::from_error_message(e, "couldnt_like_comment"))?;
} }

View file

@ -60,8 +60,7 @@ impl Perform for CreatePostLike {
// Only add the like if the score isnt 0 // Only add the like if the score isnt 0
let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1); let do_add = like_form.score != 0 && (like_form.score == 1 || like_form.score == -1);
if do_add { if do_add {
let like_form2 = like_form.clone(); PostLike::like(context.pool(), &like_form)
PostLike::like(context.pool(), &like_form2)
.await .await
.map_err(|e| LemmyError::from_error_message(e, "couldnt_like_post"))?; .map_err(|e| LemmyError::from_error_message(e, "couldnt_like_post"))?;
} }

View file

@ -107,9 +107,8 @@ impl PerformCrud for CreateComment {
.build(); .build();
// Create the comment // Create the comment
let comment_form2 = comment_form.clone();
let parent_path = parent_opt.clone().map(|t| t.path); 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 .await
.map_err(|e| LemmyError::from_error_message(e, "couldnt_create_comment"))?; .map_err(|e| LemmyError::from_error_message(e, "couldnt_create_comment"))?;