box-drawing: LIGHT ARC: use min/max instead of checking range inside loop

This commit is contained in:
Daniel Eklöf 2021-01-02 12:08:32 +01:00
parent d8e40cf5d4
commit 66497cfd4d
No known key found for this signature in database
GPG key ID: 5BBD4992C116573F

View file

@ -1275,16 +1275,11 @@ draw_box_drawings_light_arc(wchar_t wc, struct buf *buf)
assert(row_end > row_start);
assert(col_end > col_start);
for (int r = row_start; r < row_end; r++) {
if (r < 0 || r >= buf->height)
continue;
for (int c = col_start; c < col_end; c++) {
if (c >= 0 && c < buf->width) {
size_t idx = c / 8;
size_t bit_no = c % 8;
buf->data[r * buf->stride + idx] |= 1 << bit_no;
}
for (int r = max(row_start, 0); r < min(row_end, buf->height); r++) {
for (int c = max(col_start, 0); c < min(col_end, buf->width); c++) {
size_t idx = c / 8;
size_t bit_no = c % 8;
buf->data[r * buf->stride + idx] |= 1 << bit_no;
}
}
}