-
Notifications
You must be signed in to change notification settings - Fork 6k
[Android] ArrayList is faster than LinkedList for reasonable N. #50767
Conversation
It looks like this pull request may not have tests. Please make sure to add tests before merging. If you need an exemption to this rule, contact "@test-exemption-reviewer" in the #hackers channel in Chat (don't just cc them here, they won't see it! Use Discord!). If you are not sure if you need tests, consider this rule of thumb: the purpose of a test is to make sure someone doesn't accidentally revert the fix. Ask yourself, is there anything in your PR that you feel it is important we not accidentally revert back to how it was before your fix? Reviewers: Read the Tree Hygiene page and make sure this patch meets those guidelines before LGTMing. |
@@ -735,7 +735,7 @@ private PerImageReader getActiveReader() { | |||
// Create a new ImageReader and add it to the queue. | |||
return getOrCreatePerImageReader(createImageReader()); | |||
} | |||
return imageReaderQueue.peekLast(); | |||
return imageReaderQueue.get(imageReaderQueue.size() - 1); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Need to check length here, the peek methods return null if the size isn't enough.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Not that it much matters, but fun drive by comment to say you could use an ArrayDeque
here instead if you wanted to keep the same convenience right? (they both implement the double ended queue interface)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
That's a good idea, I will try that.
Are we making progress on this? Seems like a generally good thing to do. |
Closing as stale. |
…er with ArrayDeques (#51494) Inspired by #50767. [As their documentation notes](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayDeque.html), `ArrayDeque`s are generally faster than LinkedList when used as a queue. Fixes flutter/flutter#143721 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
…er with ArrayDeques (flutter#51494) Inspired by flutter#50767. [As their documentation notes](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayDeque.html), `ArrayDeque`s are generally faster than LinkedList when used as a queue. Fixes flutter/flutter#143721 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
…er with ArrayDeques (flutter#51494) Inspired by flutter#50767. [As their documentation notes](https://docs.oracle.com/javase/8/docs/api/java/util/ArrayDeque.html), `ArrayDeque`s are generally faster than LinkedList when used as a queue. Fixes flutter/flutter#143721 [C++, Objective-C, Java style guides]: https://github.com/flutter/engine/blob/main/CONTRIBUTING.md#style
Fixes flutter/flutter#143721
Java LinkedList is just slooow.