Skip to content

Reduce recusion to save stack space #5

@qwelyt

Description

@qwelyt

In places like

fn get_key(position: &Position, layer: u8) -> Option<Key> {
match LAYOUT.get_key(layer, position) {
Key::KeyCode(kc) => Some(Key::KeyCode(kc)),
Key::Function(f) => Some(Key::Function(f)),
Key::PassThrough(go_down) => State::get_key(position, layer - go_down),
_ => None
}
}
there is a recursion happening, wasting stack space.

As the stack is quite limited it would be good to rewrite this part (and others like it) to remove the recursion. Do a loop instead.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions