diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-01-24 08:43:51 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-24 08:43:51 +0800 |
commit | fa12b9ca2b1dd5515910875e04fe36564fbaadcc (patch) | |
tree | a9db5e808937b47883a341eabda44af00e0df878 /src/nvim/grid.c | |
parent | dbb6c7f1b8bed789f5bebb73be332c063fc6a604 (diff) | |
download | rneovim-fa12b9ca2b1dd5515910875e04fe36564fbaadcc.tar.gz rneovim-fa12b9ca2b1dd5515910875e04fe36564fbaadcc.tar.bz2 rneovim-fa12b9ca2b1dd5515910875e04fe36564fbaadcc.zip |
vim-patch:partial:9.0.1237: code is indented more than necessary (#21971)
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes vim/vim#11858)
https://github.com/vim/vim/commit/6ec66660476562e643deceb7c325cd0e8c903663
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/grid.c')
-rw-r--r-- | src/nvim/grid.c | 12 |
1 files changed, 6 insertions, 6 deletions
diff --git a/src/nvim/grid.c b/src/nvim/grid.c index 4702e224c6..46f8a59710 100644 --- a/src/nvim/grid.c +++ b/src/nvim/grid.c @@ -142,16 +142,16 @@ void grid_putchar(ScreenGrid *grid, int c, int row, int col, int attr) /// Also return its attribute in *attrp; void grid_getbytes(ScreenGrid *grid, int row, int col, char *bytes, int *attrp) { - size_t off; - grid_adjust(&grid, &row, &col); // safety check - if (grid->chars != NULL && row < grid->rows && col < grid->cols) { - off = grid->line_offset[row] + (size_t)col; - *attrp = grid->attrs[off]; - schar_copy(bytes, grid->chars[off]); + if (grid->chars == NULL || row >= grid->rows || col >= grid->cols) { + return; } + + size_t off = grid->line_offset[row] + (size_t)col; + *attrp = grid->attrs[off]; + schar_copy(bytes, grid->chars[off]); } /// put string '*text' on the window grid at position 'row' and 'col', with |