Commit 6ff9631
Fix
Prevent `FakeExtractorInput` from performing expensive array resizing
operations (`Booleans.ensureCapacity`) during standard reads or peeks
where `simulatePartialReads` is disabled.
Previously, the code attempted to resize the tracking arrays on every
read operation. When `simulatePartialReads` is false, these arrays are
initialized with a size of `0`, causing a mandatory allocation and
array-copy for every single read. For large media files, this resulted
in `O(N^2)` complexity and test timeouts.
This change adds a guard to ensure resizing only occurs when the
partial read simulation feature is actually active, restoring linear
`O(N)` performance.
#cherrypick
PiperOrigin-RevId: 865504874
(cherry picked from commit dcd4463)FakeExtractorInput O(N^2) resizing during reads and peeks1 parent 9b355f7 commit 6ff9631
1 file changed
Lines changed: 18 additions & 17 deletions
Lines changed: 18 additions & 17 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
265 | 265 | | |
266 | 266 | | |
267 | 267 | | |
268 | | - | |
269 | | - | |
270 | | - | |
271 | | - | |
272 | | - | |
273 | | - | |
274 | | - | |
275 | | - | |
276 | | - | |
277 | | - | |
278 | | - | |
| 268 | + | |
| 269 | + | |
| 270 | + | |
| 271 | + | |
| 272 | + | |
| 273 | + | |
| 274 | + | |
| 275 | + | |
| 276 | + | |
| 277 | + | |
| 278 | + | |
| 279 | + | |
| 280 | + | |
| 281 | + | |
| 282 | + | |
| 283 | + | |
| 284 | + | |
279 | 285 | | |
280 | 286 | | |
281 | | - | |
282 | | - | |
283 | | - | |
284 | | - | |
285 | | - | |
286 | | - | |
| 287 | + | |
287 | 288 | | |
288 | 289 | | |
289 | 290 | | |
| |||
0 commit comments