natecraddock / zf

a commandline fuzzy finder and zig module designed for filtering filepaths
MIT License
469 stars 17 forks source link

Can we use `comptime` to de-duplicate the ranking and highlighting code? #31

Closed natecraddock closed 1 year ago

natecraddock commented 1 year ago

Currently the ranking and highlighting code is duplicated in filter.zig (rankToken() and highlightToken()). This makes some things more clear (each function returns a specific type, no unneeded args), and it also should make the function more performant. But it is an occasional burden to remember to update both functions.

A quick brainthought makes me think we could leverage comptime arguments to specify which version of the function to use (return the rank vs return the matched buffers) and not suffer any runtime performance penalty. I'll look into this...

natecraddock commented 1 year ago

I don't think this is worth it. Maybe I'll look at it again later