Răsfoiți Sursa

faster and less bits... again

Jeremiah 8 ani în urmă
părinte
comite
63d9698d5c
1 a modificat fișierele cu 5 adăugiri și 6 ștergeri
  1. 5 6
      tmk_core/common/keyboard.c

+ 5 - 6
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;
     return out;
 }
 }
 
 
-
+static inline bool countones(matrix_row_t row)
-static inline bool countones(matrix_row_t data)
 {
 {
     int count = 0;
     int count = 0;
-    for (int col = 0; col < MATRIX_COLS; col++) {
+    while (row > 0){
-        if (data & (1<<col)){
+        count += 1;
-            count++;
+        row &= row-1;
-        }
     }
     }
     if (count > 1){
     if (count > 1){
         return true;
         return true;
     }
     }
     return false;
     return false;
 }
 }
+
 static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata)
 static inline bool has_ghost_in_row(uint8_t row, matrix_row_t rowdata)
 {
 {
     rowdata = get_real_keys(row, rowdata);
     rowdata = get_real_keys(row, rowdata);