Commit 03d964d
authored
perf: Stop creating error before needing to throw (#3664)
Stop creating `Error` and passing into `assert`, especially in hot paths
as it takes a significant amount of time on mobile.
<!-- CURSOR_SUMMARY -->
---
> [!NOTE]
> Replaces `assert(..., new Error(...))` with string messages in
`SnapController` and `Timer` to avoid unnecessary Error construction.
>
> - **Performance refactor**
> - `packages/snaps-controllers/src/snaps/SnapController.ts`
> - Use `assert(condition, "message")` instead of creating `Error` in
`getExpect`, `#createRollbackSnapshot` (2 sites), and
`#getRuntimeExpect`.
> - `packages/snaps-controllers/src/snaps/Timer.ts`
> - Same change in `cancel`, `finish`, `pause`, `start`, and `resume`.
>
> <sup>Written by [Cursor
Bugbot](https://cursor.com/dashboard?tab=bugbot) for commit
8c15196. This will update automatically
on new commits. Configure
[here](https://cursor.com/dashboard?tab=bugbot).</sup>
<!-- /CURSOR_SUMMARY -->1 parent 93f69e5 commit 03d964d
File tree
2 files changed
+9
-18
lines changed- packages/snaps-controllers/src/snaps
2 files changed
+9
-18
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1952 | 1952 | | |
1953 | 1953 | | |
1954 | 1954 | | |
1955 | | - | |
| 1955 | + | |
1956 | 1956 | | |
1957 | 1957 | | |
1958 | 1958 | | |
| |||
4169 | 4169 | | |
4170 | 4170 | | |
4171 | 4171 | | |
4172 | | - | |
| 4172 | + | |
4173 | 4173 | | |
4174 | 4174 | | |
4175 | 4175 | | |
| |||
4182 | 4182 | | |
4183 | 4183 | | |
4184 | 4184 | | |
4185 | | - | |
| 4185 | + | |
4186 | 4186 | | |
4187 | 4187 | | |
4188 | 4188 | | |
| |||
4272 | 4272 | | |
4273 | 4273 | | |
4274 | 4274 | | |
4275 | | - | |
4276 | | - | |
4277 | | - | |
4278 | | - | |
| 4275 | + | |
4279 | 4276 | | |
4280 | 4277 | | |
4281 | 4278 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
54 | 54 | | |
55 | 55 | | |
56 | 56 | | |
57 | | - | |
| 57 | + | |
58 | 58 | | |
59 | 59 | | |
60 | 60 | | |
| |||
65 | 65 | | |
66 | 66 | | |
67 | 67 | | |
68 | | - | |
69 | | - | |
70 | | - | |
71 | | - | |
| 68 | + | |
72 | 69 | | |
73 | 70 | | |
74 | 71 | | |
| |||
80 | 77 | | |
81 | 78 | | |
82 | 79 | | |
83 | | - | |
| 80 | + | |
84 | 81 | | |
85 | 82 | | |
86 | 83 | | |
| |||
102 | 99 | | |
103 | 100 | | |
104 | 101 | | |
105 | | - | |
| 102 | + | |
106 | 103 | | |
107 | 104 | | |
108 | 105 | | |
| |||
116 | 113 | | |
117 | 114 | | |
118 | 115 | | |
119 | | - | |
120 | | - | |
121 | | - | |
122 | | - | |
| 116 | + | |
123 | 117 | | |
124 | 118 | | |
125 | 119 | | |
| |||
0 commit comments