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:
@@ -715,12 +715,12 @@ rec {
|
|||||||
getName pkgs.youtube-dl
|
getName pkgs.youtube-dl
|
||||||
=> "youtube-dl"
|
=> "youtube-dl"
|
||||||
*/
|
*/
|
||||||
getName = x:
|
getName = let
|
||||||
let
|
parse = drv: (parseDrvName drv).name;
|
||||||
parse = drv: (parseDrvName drv).name;
|
in x:
|
||||||
in if isString x
|
if isString x
|
||||||
then parse x
|
then parse x
|
||||||
else x.pname or (parse x.name);
|
else x.pname or (parse x.name);
|
||||||
|
|
||||||
/* This function takes an argument that's either a derivation or a
|
/* This function takes an argument that's either a derivation or a
|
||||||
derivation's "name" attribute and extracts the version part from that
|
derivation's "name" attribute and extracts the version part from that
|
||||||
@@ -732,12 +732,12 @@ rec {
|
|||||||
getVersion pkgs.youtube-dl
|
getVersion pkgs.youtube-dl
|
||||||
=> "2016.01.01"
|
=> "2016.01.01"
|
||||||
*/
|
*/
|
||||||
getVersion = x:
|
getVersion = let
|
||||||
let
|
parse = drv: (parseDrvName drv).version;
|
||||||
parse = drv: (parseDrvName drv).version;
|
in x:
|
||||||
in if isString x
|
if isString x
|
||||||
then parse x
|
then parse x
|
||||||
else x.version or (parse x.name);
|
else x.version or (parse x.name);
|
||||||
|
|
||||||
/* Extract name with version from URL. Ask for separator which is
|
/* Extract name with version from URL. Ask for separator which is
|
||||||
supposed to start extension.
|
supposed to start extension.
|
||||||
|
|||||||
Reference in New Issue
Block a user