aboutsummaryrefslogtreecommitdiff
path: root/fuzzel.lua
diff options
context:
space:
mode:
authorAlexander Pickering <alexandermpickering@gmail.com>2016-06-06 15:14:14 -0400
committerAlexander Pickering <alexandermpickering@gmail.com>2016-06-06 15:14:14 -0400
commitf9f102045096143998e75294dc3d409fc807819e (patch)
tree220c7d71e878644a2b845091b6db753470ee0cdf /fuzzel.lua
parent1c70e2dcaebe1bb18ec7d28f2caf2495efd5717d (diff)
downloadfuzzel-f9f102045096143998e75294dc3d409fc807819e.tar.gz
fuzzel-f9f102045096143998e75294dc3d409fc807819e.tar.bz2
fuzzel-f9f102045096143998e75294dc3d409fc807819e.zip
Added an optimization in fuzzy sorting
Diffstat (limited to 'fuzzel.lua')
-rw-r--r--fuzzel.lua10
1 files changed, 5 insertions, 5 deletions
diff --git a/fuzzel.lua b/fuzzel.lua
index f3432dc..894fd07 100644
--- a/fuzzel.lua
+++ b/fuzzel.lua
@@ -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