krisk / fuse-swift

A lightweight fuzzy-search library, with zero dependencies
MIT License
934 stars 112 forks source link

Performance improvements #31

Closed peteraisher closed 5 years ago

peteraisher commented 5 years ago

Several improvements to the internals of _search(_:in:) to avoid the less efficient parts of Swift's String implementation, namely the fact that count is O(n) for a string of length n, and String.index(_, offsetBy: n) is also O(n).

Overall speedup of up to 2.5x for search operations.

FuseUtilities.swift:

Fuse.swift:

String+Fuse.swift:

mthole-old commented 5 years ago

Nice work!

krisk commented 5 years ago

Amazing work @peteraisher!

peteraisher commented 5 years ago

Thanks @krisk, glad you approve!