From 97e64e2cafed73fa665dfa5a5f8d20d0abff84c8 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?Daniel=20Ekl=C3=B6f?= Date: Thu, 5 Aug 2021 18:29:07 +0200 Subject: [PATCH] box-drawing: wedges: pre-load x_halfs[] and y_thirds[] This reduces the number of loads in the rest of the function. --- box-drawing.c | 135 ++++++++++++++++++++++++++------------------------ 1 file changed, 71 insertions(+), 64 deletions(-) diff --git a/box-drawing.c b/box-drawing.c index 4a405b4e..7f146826 100644 --- a/box-drawing.c +++ b/box-drawing.c @@ -2118,242 +2118,249 @@ draw_wedge_triangle(struct buf *buf, wchar_t wc) const int width = buf->width; const int height = buf->height; + int halfs0 = buf->x_halfs[0]; + int halfs1 = buf->x_halfs[1]; + int thirds0 = buf->y_thirds[0]; + int thirds1 = buf->y_thirds[1]; + int thirds2 = buf->y_thirds[2]; + int thirds3 = buf->y_thirds[3]; + int p1_x, p1_y, p2_x, p2_y, p3_x, p3_y; switch (wc) { case 0x1fb3c: /* ๐Ÿฌผ */ - p1_x = p2_x = 0; p3_x = buf->x_halfs[0]; - p1_y = buf->y_thirds[3]; p2_y = p3_y = height; + p1_x = p2_x = 0; p3_x = halfs0; + p1_y = thirds3; p2_y = p3_y = height; break; case 0x1fb52: /* ๐Ÿญ’ */ - p1_x = p2_x = 0; p3_x = buf->x_halfs[0]; - p1_y = buf->y_thirds[2]; p2_y = p3_y = height; + p1_x = p2_x = 0; p3_x = halfs0; + p1_y = thirds2; p2_y = p3_y = height; break; case 0x1fb3d: /* ๐Ÿฌฝ */ p1_x = p2_x = 0; p3_x = width; - p1_y = buf->y_thirds[3]; p2_y = p3_y = height; + p1_y = thirds3; p2_y = p3_y = height; break; case 0x1fb53: /* ๐Ÿญ“ */ p1_x = p2_x = 0; p3_x = width; - p1_y = buf->y_thirds[2]; p2_y = p3_y = height; + p1_y = thirds2; p2_y = p3_y = height; break; case 0x1fb3e: /* ๐Ÿฌพ */ - p1_x = p2_x = 0; p3_x = buf->x_halfs[0]; - p1_y = buf->y_thirds[1]; p2_y = p3_y = height; + p1_x = p2_x = 0; p3_x = halfs0; + p1_y = thirds1; p2_y = p3_y = height; break; case 0x1fb54: /* ๐Ÿญ” */ - p1_x = p2_x = 0; p3_x = buf->x_halfs[0]; - p1_y = buf->y_thirds[0]; p2_y = p3_y = height; + p1_x = p2_x = 0; p3_x = halfs0; + p1_y = thirds0; p2_y = p3_y = height; break; case 0x1fb3f: /* ๐Ÿฌฟ */ p1_x = p2_x = 0; p3_x = width; - p1_y = buf->y_thirds[1]; p2_y = p3_y = height; + p1_y = thirds1; p2_y = p3_y = height; break; case 0x1fb55: /* ๐Ÿญ• */ p1_x = p2_x = 0; p3_x = width; - p1_y = buf->y_thirds[0]; p2_y = p3_y = height; + p1_y = thirds0; p2_y = p3_y = height; break; case 0x1fb40: /* ๐Ÿญ€ */ case 0x1fb56: /* ๐Ÿญ– */ - p1_x = p2_x = 0; p3_x = buf->x_halfs[0]; + p1_x = p2_x = 0; p3_x = halfs0; p1_y = 0; p2_y = p3_y = height; break; case 0x1fb47: /* ๐Ÿญ‡ */ - p1_x = p2_x = width; p3_x = buf->x_halfs[1]; - p1_y = buf->y_thirds[3]; p2_y = p3_y = height; + p1_x = p2_x = width; p3_x = halfs1; + p1_y = thirds3; p2_y = p3_y = height; break; case 0x1fb5d: /* ๐Ÿญ */ - p1_x = p2_x = width; p3_x = buf->x_halfs[1]; - p1_y = buf->y_thirds[2]; p2_y = p3_y = height; + p1_x = p2_x = width; p3_x = halfs1; + p1_y = thirds2; p2_y = p3_y = height; break; case 0x1fb48: /* ๐Ÿญˆ */ p1_x = p2_x = width; p3_x = 0; - p1_y = buf->y_thirds[3]; p2_y = p3_y = height; + p1_y = thirds3; p2_y = p3_y = height; break; case 0x1fb5e: /* ๐Ÿญž */ p1_x = p2_x = width; p3_x = 0; - p1_y = buf->y_thirds[2]; p2_y = p3_y = height; + p1_y = thirds2; p2_y = p3_y = height; break; case 0x1fb49: /* ๐Ÿญ‰ */ - p1_x = p2_x = width; p3_x = buf->x_halfs[1]; - p1_y = buf->y_thirds[1]; p2_y = p3_y = height; + p1_x = p2_x = width; p3_x = halfs1; + p1_y = thirds1; p2_y = p3_y = height; break; case 0x1fb5f: /* ๐ŸญŸ */ - p1_x = p2_x = width; p3_x = buf->x_halfs[1]; - p1_y = buf->y_thirds[0]; p2_y = p3_y = height; + p1_x = p2_x = width; p3_x = halfs1; + p1_y = thirds0; p2_y = p3_y = height; break; case 0x1fb4a: /* ๐ŸญŠ */ p1_x = p2_x = width; p3_x = 0; - p1_y = buf->y_thirds[1]; p2_y = p3_y = height; + p1_y = thirds1; p2_y = p3_y = height; break; case 0x1fb60: /* ๐Ÿญ  */ p1_x = p2_x = width; p3_x = 0; - p1_y = buf->y_thirds[0]; p2_y = p3_y = height; + p1_y = thirds0; p2_y = p3_y = height; break; case 0x1fb4b: /* ๐Ÿญ‹ */ case 0x1fb61: /* ๐Ÿญก */ - p1_x = p2_x = width; p3_x = buf->x_halfs[1]; + p1_x = p2_x = width; p3_x = halfs1; p1_y = 0; p2_y = p3_y = height; break; case 0x1fb57: /* ๐Ÿญ— */ - p1_x = p2_x = 0; p3_x = buf->x_halfs[0]; - p1_y = p3_y = 0; p2_y = buf->y_thirds[0]; + p1_x = p2_x = 0; p3_x = halfs0; + p1_y = p3_y = 0; p2_y = thirds0; break; case 0x1fb41: /* ๐Ÿญ */ - p1_x = p2_x = 0; p3_x = buf->x_halfs[0]; - p1_y = p3_y = 0; p2_y = buf->y_thirds[1]; + p1_x = p2_x = 0; p3_x = halfs0; + p1_y = p3_y = 0; p2_y = thirds1; break; case 0x1fb58: /* ๐Ÿญ˜ */ p1_x = p2_x = 0; p3_x = width; - p1_y = p3_y = 0; p2_y = buf->y_thirds[0]; + p1_y = p3_y = 0; p2_y = thirds0; break; case 0x1fb42: /* ๐Ÿญ‚ */ p1_x = p2_x = 0; p3_x = width; - p1_y = p3_y = 0; p2_y = buf->y_thirds[1]; + p1_y = p3_y = 0; p2_y = thirds1; break; case 0x1fb59: /* ๐Ÿญ™ */ - p1_x = p2_x = 0; p3_x = buf->x_halfs[0]; - p1_y = p3_y = 0; p2_y = buf->y_thirds[2]; + p1_x = p2_x = 0; p3_x = halfs0; + p1_y = p3_y = 0; p2_y = thirds2; break; case 0x1fb43: /* ๐Ÿญƒ */ - p1_x = p2_x = 0; p3_x = buf->x_halfs[0]; - p1_y = p3_y = 0; p2_y = buf->y_thirds[3]; + p1_x = p2_x = 0; p3_x = halfs0; + p1_y = p3_y = 0; p2_y = thirds3; break; case 0x1fb5a: /* ๐Ÿญš */ p1_x = p2_x = 0; p3_x = width; - p1_y = p3_y = 0; p2_y = buf->y_thirds[2]; + p1_y = p3_y = 0; p2_y = thirds2; break; case 0x1fb44: /* ๐Ÿญ„ */ p1_x = p2_x = 0; p3_x = width; - p1_y = p3_y = 0; p2_y = buf->y_thirds[3]; + p1_y = p3_y = 0; p2_y = thirds3; break; case 0x1fb5b: /* ๐Ÿญ› */ case 0x1fb45: /* ๐Ÿญ… */ - p1_x = p2_x = 0; p3_x = buf->x_halfs[0]; + p1_x = p2_x = 0; p3_x = halfs0; p1_y = p3_y = 0; p2_y = height; break; case 0x1fb62: /* ๐Ÿญข */ - p1_x = p2_x = width; p3_x = buf->x_halfs[1]; - p1_y = p3_y = 0; p2_y = buf->y_thirds[0]; + p1_x = p2_x = width; p3_x = halfs1; + p1_y = p3_y = 0; p2_y = thirds0; break; case 0x1fb4c: /* ๐ŸญŒ */ - p1_x = p2_x = width; p3_x = buf->x_halfs[1]; - p1_y = p3_y = 0; p2_y = buf->y_thirds[1]; + p1_x = p2_x = width; p3_x = halfs1; + p1_y = p3_y = 0; p2_y = thirds1; break; case 0x1fb63: /* ๐Ÿญฃ */ p1_x = p2_x = width; p3_x = 0; - p1_y = p3_y = 0; p2_y = buf->y_thirds[0]; + p1_y = p3_y = 0; p2_y = thirds0; break; case 0x1fb4d: /* ๐Ÿญ */ p1_x = p2_x = width; p3_x = 0; - p1_y = p3_y = 0; p2_y = buf->y_thirds[1]; + p1_y = p3_y = 0; p2_y = thirds1; break; case 0x1fb64: /* ๐Ÿญค */ - p1_x = p2_x = width; p3_x = buf->x_halfs[1]; - p1_y = p3_y = 0; p2_y = buf->y_thirds[2]; + p1_x = p2_x = width; p3_x = halfs1; + p1_y = p3_y = 0; p2_y = thirds2; break; case 0x1fb4e: /* ๐ŸญŽ */ - p1_x = p2_x = width; p3_x = buf->x_halfs[1]; - p1_y = p3_y = 0; p2_y = buf->y_thirds[3]; + p1_x = p2_x = width; p3_x = halfs1; + p1_y = p3_y = 0; p2_y = thirds3; break; case 0x1fb65: /* ๐Ÿญฅ */ p1_x = p2_x = width; p3_x = 0; - p1_y = p3_y = 0; p2_y = buf->y_thirds[2]; + p1_y = p3_y = 0; p2_y = thirds2; break; case 0x1fb4f: /* ๐Ÿญ */ p1_x = p2_x = width; p3_x = 0; - p1_y = p3_y = 0; p2_y = buf->y_thirds[3]; + p1_y = p3_y = 0; p2_y = thirds3; break; case 0x1fb66: /* ๐Ÿญฆ */ case 0x1fb50: /* ๐Ÿญ */ - p1_x = p2_x = width; p3_x = buf->x_halfs[1]; + p1_x = p2_x = width; p3_x = halfs1; p1_y = p3_y = 0; p2_y = height; break; case 0x1fb46: /* ๐Ÿญ† */ - p1_x = 0; p1_y = buf->y_thirds[2]; - p2_x = width; p2_y = buf->y_thirds[1]; + p1_x = 0; p1_y = thirds2; + p2_x = width; p2_y = thirds1; p3_x = width; p3_y = p1_y; break; case 0x1fb51: /* ๐Ÿญ‘ */ - p1_x = 0; p1_y = buf->y_thirds[1]; - p2_x = 0; p2_y = buf->y_thirds[2]; + p1_x = 0; p1_y = thirds1; + p2_x = 0; p2_y = thirds2; p3_x = width; p3_y = p2_y; break; case 0x1fb5c: /* ๐Ÿญœ */ - p1_x = 0; p1_y = buf->y_thirds[1]; - p2_x = 0; p2_y = buf->y_thirds[2]; + p1_x = 0; p1_y = thirds1; + p2_x = 0; p2_y = thirds2; p3_x = width; p3_y = p1_y; break; case 0x1fb67: /* ๐Ÿญง */ - p1_x = 0; p1_y = buf->y_thirds[1]; + p1_x = 0; p1_y = thirds1; p2_x = width; p2_y = p1_y; - p3_x = width; p3_y = buf->y_thirds[2]; + p3_x = width; p3_y = thirds2; break; case 0x1fb6c: /* ๐Ÿญฌ */ case 0x1fb68: /* ๐Ÿญจ */ p1_x = 0; p1_y = 0; - p2_x = buf->x_halfs[0]; p2_y = height / 2; + p2_x = halfs0; p2_y = height / 2; p3_x = 0; p3_y = height; break; case 0x1fb6d: /* ๐Ÿญญ */ case 0x1fb69: /* ๐Ÿญฉ */ p1_x = 0; p1_y = 0; - p2_x = buf->x_halfs[1]; p2_y = height / 2; + p2_x = halfs1; p2_y = height / 2; p3_x = width; p3_y = 0; break; case 0x1fb6e: /* ๐Ÿญฎ */ case 0x1fb6a: /* ๐Ÿญช */ p1_x = width; p1_y = 0; - p2_x = buf->x_halfs[1]; p2_y = height / 2; + p2_x = halfs1; p2_y = height / 2; p3_x = width; p3_y = height; break; case 0x1fb6f: /* ๐Ÿญฏ */ case 0x1fb6b: /* ๐Ÿญซ */ p1_x = 0; p1_y = height; - p2_x = buf->x_halfs[1]; p2_y = height / 2; + p2_x = halfs1; p2_y = height / 2; p3_x = width; p3_y = height; break;