lib.strings: Dont create scopes for getName/getVersion
We can create the `parse` function in a scope one level up to avoid recomputing it every time.
This commit is contained in:
parent
b571c88ad3
commit
bd817120c4
@ -715,12 +715,12 @@ rec {
|
||||
getName pkgs.youtube-dl
|
||||
=> "youtube-dl"
|
||||
*/
|
||||
getName = x:
|
||||
let
|
||||
parse = drv: (parseDrvName drv).name;
|
||||
in if isString x
|
||||
then parse x
|
||||
else x.pname or (parse x.name);
|
||||
getName = let
|
||||
parse = drv: (parseDrvName drv).name;
|
||||
in x:
|
||||
if isString x
|
||||
then parse x
|
||||
else x.pname or (parse x.name);
|
||||
|
||||
/* This function takes an argument that's either a derivation or a
|
||||
derivation's "name" attribute and extracts the version part from that
|
||||
@ -732,12 +732,12 @@ rec {
|
||||
getVersion pkgs.youtube-dl
|
||||
=> "2016.01.01"
|
||||
*/
|
||||
getVersion = x:
|
||||
let
|
||||
parse = drv: (parseDrvName drv).version;
|
||||
in if isString x
|
||||
then parse x
|
||||
else x.version or (parse x.name);
|
||||
getVersion = let
|
||||
parse = drv: (parseDrvName drv).version;
|
||||
in x:
|
||||
if isString x
|
||||
then parse x
|
||||
else x.version or (parse x.name);
|
||||
|
||||
/* Extract name with version from URL. Ask for separator which is
|
||||
supposed to start extension.
|
||||
|
Loading…
Reference in New Issue
Block a user