From d3fb69cf129fe70c932a5d82fdd1bcc613544b5b Mon Sep 17 00:00:00 2001 From: Joris Date: Sun, 27 Nov 2022 15:38:39 +0100 Subject: Speed up deck synchronization Apply changes for what has been inserted, updated, removed. Also use transactions to speed up multi-writing. --- src/gui/question.rs | 10 ++++++---- 1 file changed, 6 insertions(+), 4 deletions(-) (limited to 'src/gui/question.rs') diff --git a/src/gui/question.rs b/src/gui/question.rs index 71c3ea2..2aa6e65 100644 --- a/src/gui/question.rs +++ b/src/gui/question.rs @@ -1,6 +1,6 @@ use crate::{ gui::util, - model::{card::Card, difficulty, difficulty::Difficulty}, + model::{difficulty, difficulty::Difficulty, Card}, util::event::{Event, Events}, util::serialization, }; @@ -150,7 +150,9 @@ pub fn ask( Key::Char(c) => { state.input.push(c); if is_correct(&state.input, &card.responses) { - state.answer = Answer::Difficulty { difficulty: Difficulty::Good } + state.answer = Answer::Difficulty { + difficulty: Difficulty::Good, + } } } Key::Backspace => { @@ -161,12 +163,12 @@ pub fn ask( } Key::Ctrl('w') => { let mut words = state.input.split_whitespace().collect::>(); - if words.len() > 0 { + if !words.is_empty() { words.truncate(words.len() - 1); state.input = format!( "{}{}", words.join(" "), - if words.len() > 0 { " " } else { "" } + if !words.is_empty() { " " } else { "" } ); } } -- cgit v1.2.3