mirror of
https://github.com/PhotonVision/photonvision
synced 2026-06-21 01:01:41 +00:00
Set the initial capacity of ArrayLists in getAllUnreadResults() (#2079)
If there are more than 10 queued results, PhotonCamera.getAllUnreadResults() would resize two arrays at least once each. ## Meta Merge checklist: - [x] Pull Request title is [short, imperative summary](https://cbea.ms/git-commit/) of proposed changes - [x] The description documents the _what_ and _why_ - [ ] If this PR changes behavior or adds a feature, user documentation is updated - [ ] If this PR touches photon-serde, all messages have been regenerated and hashes have not changed unexpectedly - [ ] If this PR touches configuration, this is backwards compatible with settings back to v2024.3.1 - [ ] If this PR touches pipeline settings or anything related to data exchange, the frontend typing is updated - [ ] If this PR addresses a bug, a regression test for it is added
This commit is contained in:
@@ -101,11 +101,10 @@ public class PacketSubscriber<T> implements AutoCloseable {
|
||||
}
|
||||
|
||||
public List<PacketResult<T>> getAllChanges() {
|
||||
List<PacketResult<T>> ret = new ArrayList<>();
|
||||
|
||||
// Get /all/ changes since last call to readQueue
|
||||
var changes = subscriber.readQueue();
|
||||
|
||||
List<PacketResult<T>> ret = new ArrayList<>(changes.length);
|
||||
for (var change : changes) {
|
||||
ret.add(parse(change.value, change.timestamp));
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user