Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

get_cell_by_column_and_row etc. function can be more efficient #32

Closed
cstkingkey opened this issue Mar 12, 2022 · 2 comments
Closed

get_cell_by_column_and_row etc. function can be more efficient #32

cstkingkey opened this issue Mar 12, 2022 · 2 comments

Comments

@cstkingkey
Copy link

cstkingkey commented Mar 12, 2022

for example

for cell in &mut self.index {

when calling get_cell_by_column_and_row_mut to get a new cell, it will basically enumerate all cells two times.

I think that using hashmap with coordinate as the key to store the cells is better idea.

pub struct Cells {
    index: HashMap<(usize,usize), Cell>,
    default_cell_value: CellValue,
    default_style: Style,
}

pub fn get_cell_by_column_and_row_mut(&mut self, col: usize, row: usize) -> &mut Cell {
    let c = self.map.entry((col, row)).or_insert(Cell::default());
    c
}
@MathNya
Copy link
Owner

MathNya commented Mar 12, 2022

Thank you for your suggestion.
This seems to be a more efficient way of processing.
We will test it and if it is confirmed that there is no problem, we will address it in the next version update.

MathNya pushed a commit that referenced this issue Mar 16, 2022
Processing speed improvement #32
@MathNya
Copy link
Owner

MathNya commented Mar 16, 2022

The program has been corrected.
Please obtain and review the latest version.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants