diff options
| author | Alexander Pickering <alexandermpickering@gmail.com> | 2016-06-06 15:14:14 -0400 |
|---|---|---|
| committer | Alexander Pickering <alexandermpickering@gmail.com> | 2016-06-06 15:14:14 -0400 |
| commit | f9f102045096143998e75294dc3d409fc807819e (patch) | |
| tree | 220c7d71e878644a2b845091b6db753470ee0cdf | |
| parent | 1c70e2dcaebe1bb18ec7d28f2caf2495efd5717d (diff) | |
| download | fuzzel-f9f102045096143998e75294dc3d409fc807819e.tar.gz fuzzel-f9f102045096143998e75294dc3d409fc807819e.tar.bz2 fuzzel-f9f102045096143998e75294dc3d409fc807819e.zip | |
Added an optimization in fuzzy sorting
| -rw-r--r-- | fuzzel.lua | 10 |
1 files changed, 5 insertions, 5 deletions
@@ -223,17 +223,17 @@ local function FuzzySort(str, func, ...) --Roughly sort everything by it's distance to the string local usorted = {} + local sorted = {} for k,v in prs(looparg) do local dist = func(str,v) - usorted[dist] = usorted[dist] or {} + if usorted[dist] == nil then + usorted[dist] = {} + tblins(sorted,dist) + end tblins(usorted[dist],v) end --Actually sort them into something can can be iterated with ipairs - local sorted = {} - for k,v in prs(usorted) do - tblins(sorted,k) - end tblsrt(sorted) --Then build our output table |
