Skip to content

Commit

Permalink
Reorganise selection in InitWith code
Browse files Browse the repository at this point in the history
- Make it more compact.
- When cell found, jump to end of routine instead of looping through
  the rest of the cells in the grid.
  • Loading branch information
tobiolo committed Aug 24, 2023
1 parent e88dd95 commit 8c933e8
Showing 1 changed file with 7 additions and 9 deletions.
16 changes: 7 additions & 9 deletions src/document.h
Original file line number Diff line number Diff line change
Expand Up @@ -139,19 +139,17 @@ struct Document {

void InitWith(Cell *r, wxString filename, Cell *ics, int xs, int ys) {
rootgrid = r;
if (ics) {
Grid* ipg = ics->parent->grid;
if (ipg) {
foreachcellingrid(c, ipg) {
if (c == ics) {
SetSelect(Selection(ipg, x, y, xs, ys));
}
}
Grid* ipg = ics ? ics->parent->grid : nullptr;
if (ipg) {
foreachcellingrid(c, ipg) if (c == ics) {
SetSelect(Selection(ipg, x, y, xs, ys));
goto cellisselected;
}
} else {
SetSelect(Selection(r->grid, 0, 0, 1, 1));
}
ChangeFileName(filename, false);
cellisselected:
ChangeFileName(filename, false);
}

void UpdateFileName(int page = -1) {
Expand Down

0 comments on commit 8c933e8

Please sign in to comment.