mirror of
https://github.com/NixOS/nixpkgs.git
synced 2025-06-11 04:05:40 +03:00
lib.callPackageWith: Optimize levenshtein sort
Probably not significant because of the limits already applied. This is mostly cleanup.
This commit is contained in:
parent
67cc78643d
commit
016993237f
1 changed files with 2 additions and 2 deletions
|
@ -5,7 +5,7 @@ let
|
||||||
intersectAttrs;
|
intersectAttrs;
|
||||||
inherit (lib)
|
inherit (lib)
|
||||||
functionArgs isFunction mirrorFunctionArgs isAttrs setFunctionArgs
|
functionArgs isFunction mirrorFunctionArgs isAttrs setFunctionArgs
|
||||||
optionalAttrs attrNames filter elemAt concatStringsSep sort take length
|
optionalAttrs attrNames filter elemAt concatStringsSep sortOn take length
|
||||||
filterAttrs optionalString flip pathIsDirectory head pipe isDerivation listToAttrs
|
filterAttrs optionalString flip pathIsDirectory head pipe isDerivation listToAttrs
|
||||||
mapAttrs seq flatten deepSeq warnIf isInOldestRelease extends
|
mapAttrs seq flatten deepSeq warnIf isInOldestRelease extends
|
||||||
;
|
;
|
||||||
|
@ -174,7 +174,7 @@ rec {
|
||||||
# levenshteinAtMost is only fast for 2 or less.
|
# levenshteinAtMost is only fast for 2 or less.
|
||||||
(filter (levenshteinAtMost 2 arg))
|
(filter (levenshteinAtMost 2 arg))
|
||||||
# Put strings with shorter distance first
|
# Put strings with shorter distance first
|
||||||
(sort (x: y: levenshtein x arg < levenshtein y arg))
|
(sortOn (levenshtein arg))
|
||||||
# Only take the first couple results
|
# Only take the first couple results
|
||||||
(take 3)
|
(take 3)
|
||||||
# Quote all entries
|
# Quote all entries
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue