Skip to content

Commit 885734a

Browse files
authored
Merge pull request rails#54404 from byroot/inline-isolated-state
Inline `IsolatedExecutionState#state`
2 parents e03f459 + d09d580 commit 885734a

File tree

1 file changed

+7
-9
lines changed

1 file changed

+7
-9
lines changed

activesupport/lib/active_support/isolated_execution_state.rb

Lines changed: 7 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -33,23 +33,26 @@ def unique_id
3333
end
3434

3535
def [](key)
36-
state[key]
36+
if state = @scope.current.active_support_execution_state
37+
state[key]
38+
end
3739
end
3840

3941
def []=(key, value)
42+
state = (@scope.current.active_support_execution_state ||= {})
4043
state[key] = value
4144
end
4245

4346
def key?(key)
44-
state.key?(key)
47+
@scope.current.active_support_execution_state&.key?(key)
4548
end
4649

4750
def delete(key)
48-
state.delete(key)
51+
@scope.current.active_support_execution_state&.delete(key)
4952
end
5053

5154
def clear
52-
state.clear
55+
@scope.current.active_support_execution_state&.clear
5356
end
5457

5558
def context
@@ -62,11 +65,6 @@ def share_with(other)
6265
# and streaming should be rethought.
6366
context.active_support_execution_state = other.active_support_execution_state.dup
6467
end
65-
66-
private
67-
def state
68-
context.active_support_execution_state ||= {}
69-
end
7068
end
7169

7270
self.isolation_level = :thread

0 commit comments

Comments
 (0)