-
Notifications
You must be signed in to change notification settings - Fork 5.8k
8303266: Prefer ArrayList to LinkedList in JImageTask #12760
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
8303266: Prefer ArrayList to LinkedList in JImageTask #12760
Conversation
👋 Welcome back aturbanov! A progress list of the required criteria for merging this PR into |
@turbanoff The following label will be automatically applied to this pull request:
When this pull request is ready to be reviewed, an "RFR" email will be sent to the corresponding mailing list. If you would like to change these labels, use the /label pull request command. |
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.
LGTM. Not sure why he used that but may have started with a linked list hashmap to track duplicate files and the dropped down to linked list. At any rate, should be fine.
@turbanoff This change now passes all automated pre-integration checks. ℹ️ This project also has non-automated pre-integration requirements. Please see the file CONTRIBUTING.md for details. After integration, the commit message for the final commit will be:
You can use pull request commands such as /summary, /contributor and /issue to adjust it as needed. At the time when this comment was updated there had been 9 new commits pushed to the
Please see this link for an up-to-date comparison between the source branch of this pull request and the ➡️ To integrate this PR with the above commit message to the |
IMHO, there is not enough value in this change to continue the review. It should be closed without integrating. |
@RogerRiggs |
I guess I should weigh in because I'm mentioned here by tweet. The main point of "stop using LinkedList" (from the tweet) is in new code. If you're writing new code and get bogged down thinking, "Hm, should I use a LinkedList or ArrayList here?" then you should probably just use ArrayList and move on. There are few use cases where LinkedList is preferable to ArrayList, and most people won't ever see them. That doesn't justify replacing existing usages of ArrayList with LinkedList. The proximate question to ask here is, "Does this change improve the JDK?" I don't see any such justification here. Functionally the replacement is intended to be the same, so this doesn't fix any actual bug. The performance is supposedly better, but it's unclear whether this actually matters in this case. However, there are risks and costs associated with such changes, including the possibility of unforeseen behavioral changes that result in test failures, and the cost of reviewer time. The only benefit mentioned is that people look at the JDK and see LinkedList being used so they think it's OK to use LinkedList in their own code. This is quite tenuous. If you want people to stop using LinkedList, it will be much more effective to get to say "use ArrayList instead of LinkedList" instead of trying to remove uses of it from the JDK. |
I should have expounded on the rationale for making only changes that are worth the time of the author and the reviewers. |
I'm ok with this, as Roger said, since we've all already looked at it. I'm not really interested in seeing 234 followup changes removing LinkedList from all over the JDK though. |
It's one of the reasons, why I don't create PRs with massive replacements. I carefully choose places in the code, where I think replacement is 100% safe.
Not sure I agree with this one. Even presence issues/PRs like this in JDK, could be used as an argument between developers, who need to choose what's better. |
Sorry, there was a markup error in my earlier comment. What I meant it to say was this: « If you want people to stop using LinkedList, it will be much more effective to get your favorite tutorial site to say "use ArrayList instead of LinkedList" instead of trying to remove uses of it from the JDK. » (I had put the italicized text in angle brackets, which I guess were interpreted as malformed markup and so the text was simply dropped.) I might as well name names here. If you do a web search for "java LinkedList" you will get hits on the usual top tutorial sites. One of them is this: https://www.w3schools.com/java/java_linkedlist.asp The whole discussion of "ArrayList vs. LinkedList" here is incredibly superficial. The summary is this:
This sort of statement is a lot more influential in getting Java developers to use LinkedList than anything the JDK does. Orders of magnitude more Java developers look at these tutorial sites than look at obscure corners of the JDK source code. If you want people to stop using LinkedList, it would be better to try to get those tutorial sites changed than to try to eradicate LinkedList from the JDK. |
/integrate |
Going to push as commit fa1cebe.
Your commit was automatically rebased without conflicts. |
@turbanoff Pushed as commit fa1cebe. 💡 You may see a message that your pull request was closed with unmerged commits. This can be safely ignored. |
LinkedList
is used as a fieldjdk.tools.jimage.JImageTask.OptionsValues#jimages
It's created, filled (with
add
) and then iterated. No removes from the head or something like this.ArrayList
should be preferred as more efficient and widely used (more chances for JIT) collection.Progress
Issue
Reviewers
Reviewing
Using
git
Checkout this PR locally:
$ git fetch https://git.openjdk.org/jdk pull/12760/head:pull/12760
$ git checkout pull/12760
Update a local copy of the PR:
$ git checkout pull/12760
$ git pull https://git.openjdk.org/jdk pull/12760/head
Using Skara CLI tools
Checkout this PR locally:
$ git pr checkout 12760
View PR using the GUI difftool:
$ git pr show -t 12760
Using diff file
Download this PR as a diff file:
https://git.openjdk.org/jdk/pull/12760.diff