]> _ Git - termbox2.git/commit
replace linear cap search with trie.
authorAdam Saponara <as@php.net>
Sun, 19 Sep 2021 01:07:56 +0000 (21:07 -0400)
committerAdam Saponara <as@php.net>
Sun, 19 Sep 2021 01:07:56 +0000 (21:07 -0400)
commitca564699628204c719af22ce5b1ea2a256965a97
tree47731050378273d62b196f5b5343ce33a4da0745
parent260f60b732e396944afbf9f29233decc08b9603d
replace linear cap search with trie.

for every input, termbox used to iterate over termcaps one
at a time, `strncmp`ing it to the input buffer. the benefit
of this approach was that it had a very simple
implementation. the downside was that it was inefficient,
increasingly so as we added more caps such as modified
arrow keys.

the trie makes it easy to detect when there are overlaps in
termcaps. the obvious one is `TB_KEY_ESC` versus all other
escape codes. in the future we can modify function
`extract_esc_cap` to, e.g., potentially return `TB_KEY_ESC`
in `TB_INPUT_ALT` mode if no further input is available
after a certain amount of time.
termbox.h
tests/test_basic/expected.ansi
tests/test_mod/expected.ansi [new file with mode: 0644]
tests/test_mod/test.php [new file with mode: 0755]