Skip to content

Commit

Permalink
Autocorrection: remove unnecessary trailing zero
Browse files Browse the repository at this point in the history
This commit is a small optimization, removing a line appending a
trailing zero to `typo_buffer`. This zero has no effect since the for
loop only accesses the buffer at earlier positions. Thanks to
@filterpaper for pointing this out.
  • Loading branch information
getreuer committed Mar 2, 2022
1 parent d8f6562 commit 90267e0
Showing 1 changed file with 2 additions and 5 deletions.
7 changes: 2 additions & 5 deletions features/autocorrection.c
Original file line number Diff line number Diff line change
Expand Up @@ -123,11 +123,8 @@ bool process_autocorrection(uint16_t keycode, keyrecord_t* record) {
// Append `keycode` to the buffer.
// NOTE: `keycode` must be a basic keycode (0-255) by this point.
typo_buffer[typo_buffer_size++] = (uint8_t) keycode;
if (typo_buffer_size < AUTOCORRECTION_MAX_LENGTH) {
typo_buffer[typo_buffer_size] = 0;
// Early return if not many characters have been buffered so far.
if (typo_buffer_size < AUTOCORRECTION_MIN_LENGTH) { return true; }
}
// Early return if not many characters have been buffered so far.
if (typo_buffer_size < AUTOCORRECTION_MIN_LENGTH) { return true; }

// Check whether the buffer ends in a typo. This is done using a trie
// stored in `autocorrection_data`.
Expand Down

0 comments on commit 90267e0

Please sign in to comment.