stdenv/problems: reverse parameter order for handlerForProblem
kind and name are more likely to stay the same. Doing this allows us to cache the kind and name when calling the handler for a problem.
This commit is contained in:
@@ -434,10 +434,10 @@ rec {
|
||||
inherit switch definedConstraints;
|
||||
handlerForProblem =
|
||||
if isString switch then
|
||||
pname: name: kind:
|
||||
kind: name: pname:
|
||||
switch
|
||||
else
|
||||
pname: name: kind:
|
||||
kind: name: pname:
|
||||
let
|
||||
switch' = switch.kindSpecific.${kind} or switch.kindFallback;
|
||||
in
|
||||
@@ -466,12 +466,14 @@ rec {
|
||||
configuredProblems = definedConstraints.kinds ++ definedConstraints.names;
|
||||
|
||||
# Filter out any problems that are always ignored in config.problems.
|
||||
# Makes sure that automatic problems can cache with just config applied
|
||||
# Makes sure to cache the condition by appliny config, and the handler
|
||||
# by applying the problem's kind and name
|
||||
automaticProblemsConfigCache = concatMap (
|
||||
problem:
|
||||
optionals (elem problem.kindName configuredProblems) [
|
||||
(problem // { condition = problem.condition config; })
|
||||
]
|
||||
optional (elem problem.kindName configuredProblems) {
|
||||
condition = problem.condition config;
|
||||
handler = handlerForProblem problem.kindName problem.kindName;
|
||||
}
|
||||
) automaticProblems;
|
||||
in
|
||||
attrs:
|
||||
@@ -480,16 +482,14 @@ rec {
|
||||
in
|
||||
if
|
||||
# Fast path for when there's no problem that needs to be handled
|
||||
# No automatic problems that needs handling
|
||||
all (
|
||||
problem:
|
||||
problem.condition attrs -> handlerForProblem pname problem.kindName problem.kindName == "ignore"
|
||||
problem: problem.condition attrs -> problem.handler pname == "ignore"
|
||||
) automaticProblemsConfigCache
|
||||
&& (
|
||||
# No manual problems
|
||||
!attrs ? meta.problems
|
||||
# Or all manual problems are ignored
|
||||
|| all (name: handlerForProblem pname name (attrs.meta.problems.${name}.kind or name) == "ignore") (
|
||||
|| all (name: handlerForProblem (attrs.meta.problems.${name}.kind or name) name pname == "ignore") (
|
||||
attrNames attrs.meta.problems
|
||||
)
|
||||
)
|
||||
@@ -504,7 +504,7 @@ rec {
|
||||
inherit name;
|
||||
# Kind falls back to the name
|
||||
kind = problem.kind or name;
|
||||
handler = handlerForProblem pname name kind;
|
||||
handler = handlerForProblem kind name pname;
|
||||
inherit problem;
|
||||
}) problems
|
||||
);
|
||||
|
||||
@@ -10,7 +10,7 @@ let
|
||||
genHandlerTest =
|
||||
let
|
||||
slowReference =
|
||||
config: package: name: kind:
|
||||
config: kind: name: package:
|
||||
# Try to find an explicit handler
|
||||
(config.problems.handlers.${package} or { }).${name}
|
||||
# Fall back, iterating through the matchers
|
||||
@@ -36,7 +36,7 @@ let
|
||||
map
|
||||
(
|
||||
name:
|
||||
map (kind: f package name kind) [
|
||||
map (kind: f kind name package) [
|
||||
"k1"
|
||||
"k2"
|
||||
"k3"
|
||||
|
||||
Reference in New Issue
Block a user