romgrk/fzy-lua-native

Luajit FFI bindings to FZY

Lua

120

98 commits

updated Oct 26, 2024

See the code

README

fzy-lua-native

Luajit FFI bindings to FZY.

Building

make

Running

luajit benchmark.lua

Results:

Lines: 100000

Native:
 -> Total: 34130
 -> Time:  69.418 ms
Original:
 -> Total: 34130
 -> Time:  835.683 ms

Notes

The C version of fzy in that repo contains 2 differences with the original:

  • the functions take a is_case_sensitive additional parameters that does what you think. It's a parameter rather than computed in the function because for our use-case, you want to compute is_case_sensitive once for needle, instead of on each iteration of the loop.
  • match_positions uses uint32_t for positions, because size_t (uint64_t) doesn't map well to lua types.

Usage

The fzy algorithm requires that you call fzy.has_match(string, needle) to prefilter all your matches. Only after that is done you can call the other functions such as fzy.positions(string, needle).

ffi
fzy
lua
luajit

Contributors

romgrk

79 commits

vigoux

10 commits

ruifm

2 commits

smolck

1 commits

romgrk/fzy-lua-native

Luajit FFI bindings to FZY

Lua

120

98 commits

updated Oct 26, 2024

See the code

README

fzy-lua-native

Luajit FFI bindings to FZY.

Building

make

Running

luajit benchmark.lua

Results:

Lines: 100000

Native:
 -> Total: 34130
 -> Time:  69.418 ms
Original:
 -> Total: 34130
 -> Time:  835.683 ms

Notes

The C version of fzy in that repo contains 2 differences with the original:

  • the functions take a is_case_sensitive additional parameters that does what you think. It's a parameter rather than computed in the function because for our use-case, you want to compute is_case_sensitive once for needle, instead of on each iteration of the loop.
  • match_positions uses uint32_t for positions, because size_t (uint64_t) doesn't map well to lua types.

Usage

The fzy algorithm requires that you call fzy.has_match(string, needle) to prefilter all your matches. Only after that is done you can call the other functions such as fzy.positions(string, needle).

ffi
fzy
lua
luajit

Contributors

romgrk

79 commits

vigoux

10 commits

ruifm

2 commits

smolck

1 commits

Languages

Lua

57.3%

C

40.3%

Makefile

2.4%