[evaluator] Avoid recording dependency sources and sinks when disabled

Short-circuit the logic here early to avoid the dependency logic if
recording is disabled.
This commit is contained in:
Hamish Knight
2025-09-12 20:39:58 +01:00
parent 8e84e6a50d
commit 850118c856
2 changed files with 7 additions and 0 deletions

View File

@@ -414,6 +414,8 @@ private:
typename std::enable_if<Request::isDependencySink>::type * = nullptr>
void handleDependencySinkRequest(const Request &r,
const typename Request::OutputType &o) {
if (!recorder.isRecordingEnabled())
return;
evaluator::DependencyCollector collector(recorder);
r.writeDependencySink(collector, o);
}
@@ -425,6 +427,8 @@ private:
template <typename Request,
typename std::enable_if<Request::isDependencySource>::type * = nullptr>
void handleDependencySourceRequest(const Request &r) {
if (!recorder.isRecordingEnabled())
return;
auto source = r.readDependencySource(recorder);
if (!source.isNull() && source.get()->isPrimary()) {
recorder.handleDependencySourceRequest(r, source.get());

View File

@@ -94,6 +94,9 @@ class DependencyRecorder {
public:
DependencyRecorder(bool shouldRecord) : shouldRecord(shouldRecord) {}
/// Whether dependency recording is enabled.
bool isRecordingEnabled() const { return shouldRecord; }
/// Push a new empty set onto the activeRequestReferences stack.
template<typename Request>
void beginRequest();