summary refs log tree commit diff
diff options
context:
space:
mode:
authorJeremiah <barrar@users.noreply.github.com>2017-05-13 19:07:05 -0700
committerJeremiah <barrar@users.noreply.github.com>2017-05-13 19:07:05 -0700
commit63d9698d5c7a088b2eb8220a9a44c8adbca86326 (patch)
tree163bed69e4f9f2467406aa52eefd684ab8bb4a84
parent37f6f92765513cd66c92178f48785d492eb06b89 (diff)
faster and less bits... again
-rw-r--r--tmk_core/common/keyboard.c11
1 files changed, 5 insertions, 6 deletions
diff --git a/tmk_core/common/keyboard.c b/tmk_core/common/keyboard.c
index d8b5dc4031..fa17ffca25 100644
--- a/tmk_core/common/keyboard.c
+++ b/tmk_core/common/keyboard.c
@@ -74,20 +74,19 @@ static matrix_row_t get_real_keys(uint8_t row, matrix_row_t rowdata){
     return out;
 }
 
-
-static inline bool countones(matrix_row_t data)
+static inline bool countones(matrix_row_t row)
 {
     int count = 0;
-    for (int col = 0; col < MATRIX_COLS; col++) {
-        if (data & (1<<col)){
-            count++;
-        }
+    while (row > 0){
+        count += 1;
+        row &= row-1;
     }
     if (count > 1){
         return true;
     }
     return false;
 }
+
 static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata)
 {
     rowdata = get_real_keys(row, rowdata);