Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/romgrk/fzy-lua-native
Luajit FFI bindings to FZY
https://github.com/romgrk/fzy-lua-native
ffi fzy lua luajit
Last synced: 7 days ago
JSON representation
Luajit FFI bindings to FZY
- Host: GitHub
- URL: https://github.com/romgrk/fzy-lua-native
- Owner: romgrk
- Created: 2020-11-03T03:26:05.000Z (about 4 years ago)
- Default Branch: master
- Last Pushed: 2024-10-21T23:03:11.000Z (13 days ago)
- Last Synced: 2024-10-22T19:37:13.971Z (12 days ago)
- Topics: ffi, fzy, lua, luajit
- Language: Lua
- Homepage:
- Size: 263 KB
- Stars: 116
- Watchers: 5
- Forks: 15
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
Awesome Lists containing this project
README
# fzy-lua-native
Luajit FFI bindings to FZY.
### Building
`make`
### Running
`luajit benchmark.lua`
Results:
```
Lines: 100000Native:
-> 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)`.