Skip to content

Commit

Permalink
Make ScopedExecutionContext no-op if !ExecutionContext::isEnabled(). (e…
Browse files Browse the repository at this point in the history
…nvoyproxy#37069)

Make `ScopedExecutionContext` no-op if `!ExecutionContext::isEnabled()`.

This saves a call to `ScopeTrackedObject::trackedStream()` when
execution context is disabled.

Commit Message: Make ScopedExecutionContext no-op if
!ExecutionContext::isEnabled().
Additional Description:
Risk Level: None.
Testing: Existing execution_context_test.cc.
Docs Changes: N/A
Release Notes: N/A
Platform Specific Features:
[Optional Runtime guard:]
[Optional Fixes #Issue]
[Optional Fixes commit #PR or SHA]
[Optional Deprecated:]
[Optional [API
Considerations](https://github.com/envoyproxy/envoy/blob/main/api/review_checklist.md):]

Signed-off-by: Bin Wu <wub@google.com>
  • Loading branch information
wu-bin authored Nov 21, 2024
1 parent 7975a2b commit eb2033e
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions envoy/common/execution_context.h
Original file line number Diff line number Diff line change
Expand Up @@ -81,8 +81,9 @@ class ScopedExecutionContext : NonCopyable {
public:
ScopedExecutionContext() : ScopedExecutionContext(nullptr) {}
ScopedExecutionContext(const ScopeTrackedObject* object)
: context_(object != nullptr ? ExecutionContext::fromStreamInfo(object->trackedStream())
: nullptr) {
: context_((object != nullptr && ExecutionContext::isEnabled())
? ExecutionContext::fromStreamInfo(object->trackedStream())
: nullptr) {
if (context_ != nullptr) {
context_->activate();
}
Expand Down

0 comments on commit eb2033e

Please sign in to comment.