Zsh Mailing List Archive
Messages sorted by: Reverse Date, Date, Thread, Author

Re: [RFC] Case-insensitive path completion in _git



On 27 Mar 2021, at 16:08, Daniel Shahaf <d.s@xxxxxxxxxxxxxxxxxx> wrote:
> What about the default use-case — no matchspec and case-sensitive
> matching?  The patch transforms a plain string to a list of character
> classes, and it's not clear to me what costs that might incur on large
> trees.

I recently learnt that ls-files actually does support case-insensitive
matching using the following syntax:

  :(icase)/foo/bar/baz

Whether there might still be performance issues with it — i ran a quick test
against the Linux tree and it looks good enough to me, but idk how to make it
conclusive:

  % hyperfine --warmup=3 \
    "git ls-files -- ${(q)PWD}/'*Kbuild*'" \
    "git ls-files -- ${(q)PWD}/'*[Kk][Bb][Uu][Ii][Ll][Dd]*'" \
    "git ls-files -- ':(icase)'${(q)PWD}/'*kbuild*'"

  Benchmark #1: git ls-files -- /home/dana/linux/'*Kbuild*'
    Time (mean ± σ):      27.4 ms ±   0.9 ms    [User: 18.5 ms, System: 8.8 ms]
    Range (min … max):    26.0 ms …  31.9 ms    102 runs

  Benchmark #2: git ls-files -- /home/dana/linux/'*[Kk][Bb][Uu][Ii][Ll][Dd]*'
    Time (mean ± σ):      71.2 ms ±   1.0 ms    [User: 62.9 ms, System: 8.2 ms]
    Range (min … max):    70.1 ms …  76.0 ms    41 runs

  Benchmark #3: git ls-files -- ':(icase)'/home/dana/linux/'*kbuild*'
    Time (mean ± σ):      32.2 ms ±   0.6 ms    [User: 23.1 ms, System: 9.1 ms]
    Range (min … max):    30.7 ms …  33.9 ms    90 runs

  Summary
    'git ls-files -- /home/dana/linux/'*Kbuild*'' ran
      1.18 ± 0.04 times faster than 'git ls-files -- ':(icase)'/home/dana/linux/'*kbuild*''
      2.60 ± 0.09 times faster than 'git ls-files -- /home/dana/linux/'*[Kk][Bb][Uu][Ii][Ll][Dd]*''

It could still be gated behind a style if it's a concern.

dana





Messages sorted by: Reverse Date, Date, Thread, Author