helix/helix-core/src
Blaž Hrastnik 9821c4dd3b Optimize Changeset::is_empty()
Checked the ASM output for these three options:

pub enum Operation {
    /// Move cursor by n characters.
    Retain(usize),
    /// Delete n characters.
    Delete(usize),
    /// Insert text at position.
    Insert(String),
}

pub struct A {
    changes: Vec<Operation>,
    len: usize,
}

impl A {
    pub fn is_empty1(&self) -> bool {
        match self.changes.as_slice() {
            [] => true,
            [Operation::Retain(_)] => true,
            _ => false,
        }
    }

    /// `true` when the set is empty.
    pub fn is_empty2(&self) -> bool {
        let len = self.changes.len();
        len == 0
        || (
            len == 1
            && self.changes[0] == Operation::Retain(self.len)
        )

    }

    pub fn is_empty3(&self) -> bool {
        match self.changes.as_slice() {
            [] | [Operation::Retain(_)] => true,
            _ => false
        }
    }

}
2021-02-16 13:39:04 +09:00
..
diagnostic.rs Total mess but it works: diagnostic marking. 2020-12-03 13:10:34 +09:00
graphemes.rs clippy lint 2020-06-02 10:49:28 +09:00
history.rs Fix undo/redo not updating the syntax tree. 2020-12-03 13:10:35 +09:00
indent.rs nix: include rust-src so rust-analyzer works correctly. 2021-01-19 16:16:15 +09:00
lib.rs Text change generation, RPC call handling. 2020-12-03 13:10:35 +09:00
macros.rs Split parts of helix-term into helix-view. 2020-09-21 18:24:16 +09:00
position.rs nix: include rust-src so rust-analyzer works correctly. 2021-01-19 16:16:15 +09:00
register.rs Simple yank/paste registers. 2020-10-13 23:13:56 +09:00
selection.rs Finally: Retain horizontal position when moving vertically. 2021-02-12 16:49:24 +09:00
state.rs fix test 2021-02-16 00:15:38 +09:00
syntax.rs transaction: Use builder methods to generate compact changesets. 2021-02-16 11:03:36 +09:00
transaction.rs Optimize Changeset::is_empty() 2021-02-16 13:39:04 +09:00