Commit 9b0e876
perf(context): optimize Context map lookups to reduce lock contention and cloning
- Replaces double HashMap lookups with a single `.get().cloned()` call.
- Uses pattern matching in `value()`, `get_func()`, and `get_variable()` to directly handle the cloned `ContextValue` variant without redundant `clone()` invocations on the inner types.
- Crucially, allows the Mutex lock to be dropped earlier in `value()` before executing arbitrary long-running inner function closures.
- Included unit tests to cover the edge cases to resolve codecov issue.
Co-authored-by: ashyanSpada <22587148+ashyanSpada@users.noreply.github.com>1 parent 75e8276 commit 9b0e876
1 file changed
Lines changed: 28 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
98 | 98 | | |
99 | 99 | | |
100 | 100 | | |
| 101 | + | |
| 102 | + | |
| 103 | + | |
| 104 | + | |
| 105 | + | |
| 106 | + | |
| 107 | + | |
| 108 | + | |
| 109 | + | |
| 110 | + | |
| 111 | + | |
| 112 | + | |
| 113 | + | |
| 114 | + | |
| 115 | + | |
| 116 | + | |
| 117 | + | |
| 118 | + | |
| 119 | + | |
| 120 | + | |
| 121 | + | |
| 122 | + | |
| 123 | + | |
| 124 | + | |
| 125 | + | |
| 126 | + | |
| 127 | + | |
| 128 | + | |
0 commit comments