]> Sergey Matveev's repositories - bfs.git/commitdiff
typo: Shrink the key_coords table
authorTavian Barnes <tavianator@tavianator.com>
Fri, 27 Oct 2023 16:17:10 +0000 (12:17 -0400)
committerTavian Barnes <tavianator@tavianator.com>
Fri, 27 Oct 2023 16:17:10 +0000 (12:17 -0400)
src/typo.c

index 305711df556b6dd879cd5bb7d92d29b29af52097..b1c5c44a20cbc07068321ef935240fb40dd0e473 100644 (file)
@@ -3,11 +3,12 @@
 
 #include "typo.h"
 #include <limits.h>
+#include <stdint.h>
 #include <stdlib.h>
 #include <string.h>
 
 // Assume QWERTY layout for now
-static const int key_coords[UCHAR_MAX + 1][3] = {
+static const int8_t key_coords[UCHAR_MAX + 1][3] = {
        ['`']  = { 0,  0, 0},
        ['~']  = { 0,  0, 1},
        ['1']  = { 3,  0, 0},
@@ -112,7 +113,7 @@ static const int key_coords[UCHAR_MAX + 1][3] = {
 };
 
 static int char_distance(char a, char b) {
-       const int *ac = key_coords[(unsigned char)a], *bc = key_coords[(unsigned char)b];
+       const int8_t *ac = key_coords[(unsigned char)a], *bc = key_coords[(unsigned char)b];
        int ret = 0;
        for (int i = 0; i < 3; ++i) {
                ret += abs(ac[i] - bc[i]);