lib.trivial: save attrset lookups in highly used functions (#520296)
This commit is contained in:
+9
-6
@@ -1101,11 +1101,10 @@ in
|
||||
```
|
||||
*/
|
||||
functionArgs =
|
||||
f:
|
||||
if f ? __functor then
|
||||
f.__functionArgs or (functionArgs (f.__functor f))
|
||||
else
|
||||
builtins.functionArgs f;
|
||||
let
|
||||
functionArgs = builtins.functionArgs;
|
||||
in
|
||||
f: if f ? __functor then f.__functionArgs or (functionArgs (f.__functor f)) else functionArgs f;
|
||||
|
||||
/**
|
||||
Check whether something is a function or something
|
||||
@@ -1123,7 +1122,11 @@ in
|
||||
isFunction : Any -> Bool
|
||||
```
|
||||
*/
|
||||
isFunction = f: builtins.isFunction f || (f ? __functor && isFunction (f.__functor f));
|
||||
isFunction =
|
||||
let
|
||||
isFunction = builtins.isFunction;
|
||||
in
|
||||
f: isFunction f || (f ? __functor && isFunction (f.__functor f));
|
||||
|
||||
/**
|
||||
`mirrorFunctionArgs f g` creates a new function `g'` with the same behavior as `g` (`g' x == g x`)
|
||||
|
||||
Reference in New Issue
Block a user