Remove dead code #81
No reviewers
Labels
No Label
No Milestone
No Assignees
2 Participants
Notifications
Due Date
No due date set.
Depends on
#80 Remove usage of Option::unwrap() in activitypub code
LemmyNet/lemmy
Reference: LemmyNet/lemmy#81
Loading…
Reference in New Issue
No description provided.
Delete Branch "remove-dead-code"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
There is just no reason to keep code around that we dont use. In the best case, it slows down compilation, and in the worst case, it introduces bugs because someone uses the wrong database function. So I removed all of it, based on the output of warnalyzer. If needed, we can always do git blame to recover that code.
Rust unit tests are failing for me on master, so I'm not sure if this breaks any tests.
Based on my test, this speeds up clean debug builds of the lemmy_server crate (excluding dependencies) from 20s to 15s. But I only tried once so this could be random fluctuation.
This needs a re-do after a merge from main. There are also some things I wanna keep because we'll use them shortly, I'll comment on them.
@ -36,4 +36,1 @@
fn delete(conn: &PgConnection, activity_id: i32) -> Result<usize, Error> {
use crate::schema::activity::dsl::*;
diesel::delete(activity.find(activity_id)).execute(conn)
Ugh, I get that these are never used... but it seems like a bad idea to change them to unimplemented and different from all the others. I'm open to it I guess tho.
Or maybe we could add a
Crud
variant without the delete function?You can just make that one optional.
Oh and then you can remove all those
unimplemented()
ones.Hrm its not showing the link well: https://stackoverflow.com/questions/51915551/how-does-one-define-optional-methods-on-traits
Ah perfect!
@ -57,4 +57,1 @@
fn delete(conn: &PgConnection, comment_id: i32) -> Result<usize, Error> {
use crate::schema::comment::dsl::*;
diesel::delete(comment.find(comment_id)).execute(conn)
Comment, post, user and community deletes shouldn't be removed, bc we will use them once we implement purge. (I think one of the chapo team was maybe working on it)
Okay, restored them.
@ -292,4 +257,0 @@
)
.execute(conn)
}
}
This should all stay here, in case we add some functionality later on where your front page hides posts you've already read.
I dont really like this thing of implementing things that might be needed in the future, because either it never gets used, or it needs to get changed anyway at that time. And in the meantime its just making things more complicated for no benefit at all. Would you be happy if I add a comment with a link to this PR, so that the previous code is easy to find?
Ugh, even removing the passing unit tests? No consider this something we will implement. I'll open up a ticket for hiding read posts.
@ -123,4 +123,1 @@
pub fn api_endpoint(&self) -> String {
format!("{}/api/v1", self.hostname)
}
Might be a good idea to use this, rather than the hardcoded
v1
string in the api.... but I spose we can remove.We will only need that once we get a v2 api, and by then it needs to be rewritten anyway. No need to make things more complicated now.
Sounds good.
Okay I added post_read back in, made the delete function optional and removed Likeable::read (which was completely unused).
Please squash when you merge.