]> git.donarmstrong.com Git - qmk_firmware.git/commitdiff
faster and less bits... again
authorJeremiah <barrar@users.noreply.github.com>
Sun, 14 May 2017 02:07:05 +0000 (19:07 -0700)
committerJeremiah <barrar@users.noreply.github.com>
Sun, 14 May 2017 02:07:05 +0000 (19:07 -0700)
tmk_core/common/keyboard.c

index d8b5dc4031d6f9a8a653438f9623c754191c2931..fa17ffca2581f1723ccfb1b22e870ab14e950dbe 100644 (file)
@@ -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);