Skip to content
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

key: optimize Matches #261

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open

key: optimize Matches #261

wants to merge 2 commits into from

Commits on Oct 2, 2022

  1. Configuration menu
    Copy the full SHA
    d497a37 View commit details
    Browse the repository at this point in the history
  2. fix: optimize the key binding match operation

    This reduces the complexity of the comparison and gets rid of the heap
    allocation on every match.
    
    Benchmark before/after (`go test -bench . -benchtime 3s -count 5 -benchmem`):
    ```
    name                old time/op    new time/op    delta
    Matches/success-32    66.9ns ± 1%    15.7ns ± 0%   -76.47%  (p=0.016 n=5+4)
    Matches/fail-32       27.9ns ± 0%    12.4ns ± 2%   -55.70%  (p=0.016 n=4+5)
    
    name                old alloc/op   new alloc/op   delta
    Matches/success-32     5.00B ± 0%     0.00B       -100.00%  (p=0.008 n=5+5)
    Matches/fail-32        0.00B          0.00B           ~     (all equal)
    
    name                old allocs/op  new allocs/op  delta
    Matches/success-32      1.00 ± 0%      0.00       -100.00%  (p=0.008 n=5+5)
    Matches/fail-32         0.00           0.00           ~     (all equal)
    ```
    knz committed Oct 2, 2022
    Configuration menu
    Copy the full SHA
    43a92fb View commit details
    Browse the repository at this point in the history