-
-
Notifications
You must be signed in to change notification settings - Fork 43.5k
[Core] Faster matrix comparison #25971
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: develop
Are you sure you want to change the base?
Conversation
quantum/matrix.h
Outdated
| void matrix_init(void); | ||
| /* scan all key states on matrix */ | ||
| uint8_t matrix_scan(void); | ||
| bool matrix_scan(void); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This changes the API that custom matrix has to implement, breaking anything that already exists.
| bool matrix_changed = false; | ||
| for (uint8_t row = 0; row < MATRIX_ROWS && !matrix_changed; row++) { | ||
| matrix_changed |= matrix_previous[row] ^ matrix_get_row(row); | ||
| } |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was intentional, as the result of matrix_scan for custom matrix is not consistently implemented.
quantum/matrix_common.c
Outdated
| changed = debounce(raw_matrix, matrix + thisHand, ROWS_PER_HAND, changed) | matrix_post_scan(); | ||
| #else | ||
| changed = debounce(raw_matrix, matrix, changed); | ||
| changed = debounce(raw_matrix, matrix, ROWS_PER_HAND, changed); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is a 4th argument being introduced again?
| } | ||
| } | ||
|
|
||
| matrix_row_t matrix_previous[MATRIX_ROWS]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Moving this increases what "full" custom matrix would have to implement, cascading changes to multiple keyboards.
5fb9fd6 to
fe75b36
Compare
Description
matrix_previous[MATRIX_ROWS]into the respectivematrix.candmatrix_common.c.matrix_scan()matrix_scan()now returns changed, rather than a comparisonmemcmpover looping per rowMy speed up went from 13800 scans to 14800 scans ~6% increase (with custom matrix) 👍
Types of Changes
Issues Fixed or Closed by This PR
Checklist