feat: list sorting #42
@ -64,8 +64,10 @@ pub(crate) fn SubtasksForm(task: Task) -> Element {
|
||||
match subtasks_query.result().value() {
|
||||
QueryResult::Ok(QueryValue::Subtasks(subtasks))
|
||||
| QueryResult::Loading(Some(QueryValue::Subtasks(subtasks))) => {
|
||||
let mut subtasks = subtasks.clone();
|
||||
subtasks.sort();
|
||||
|
||||
rsx! {
|
||||
for subtask in subtasks.clone() {
|
||||
for subtask in subtasks {
|
||||
div {
|
||||
![]() Optimize cloning within the rendering loop. Each iteration of the loop clones Improve error handling strategy. The use of **Optimize cloning within the rendering loop.**
Each iteration of the loop clones `subtask` and `task` multiple times, which can lead to significant performance overhead, especially with a large number of subtasks. Consider restructuring the code to minimize cloning, possibly by using references or restructuring the data flow to reduce the need for cloning.
---
**Improve error handling strategy.**
The use of `panic!` in the default case of the match statement handling query results is a risky approach that could lead to crashes in production. Consider replacing this with a more user-friendly error message or a recovery strategy that does not terminate the application.
<!-- This is an auto-generated comment by CodeRabbit -->
|
||||
key: "{subtask.id()}",
|
||||
class: "flex flex-row items-center gap-3",
|
||||
|
Loading…
x
Reference in New Issue
Block a user
Consider performance implications of cloning and sorting subtasks.
The addition of sorting to the subtasks is a great feature for improving the user interface. However, cloning and then sorting the entire list of subtasks could be performance-intensive, especially with a large number of subtasks. Consider optimizing this by sorting the subtasks in place if the data structure allows, or by using more efficient sorting algorithms or data structures that maintain order.