-
-
Notifications
You must be signed in to change notification settings - Fork 484
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
Fix container inefficiency in FlowArrangement.java #415
base: master
Are you sure you want to change the base?
Conversation
@@ -199,7 +199,6 @@ protected Size2D arrangeFN(BlockContainer container, Graphics2D g2, | |||
} | |||
else { | |||
// start new row |
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.
Should we not reinitialize haveItemsInRow
to false
here?
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.
The original code clears the itemsInRow
and adds an element to the itemsInRow
afterwards in the same code block.
So I think the reinitialization is not required.
@@ -3986,9 +3986,8 @@ public void handleClick(int x, int y, PlotRenderingInfo info) { | |||
* | |||
* @return A list of datasets. | |||
*/ | |||
private List<XYDataset<S>> getDatasetsMappedToDomainAxis(Integer axisIndex) { | |||
private List<XYDataset<S>> getDatasetsMappedToDomainAxis(Integer axisIndex, List<XYDataset<S>> result) { |
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 sure about efficiency, but IMHO, this makes the contract of these methods worse. Previously these were pure functions without side effects, but now there are side effects introduced. I would be pretty careful here if any performance improvement warrants changing the contract of the methods like this.
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.
Got it!
If such changes cause some concerns, I will undo these changes in the next commit.
@RockyMM Thank you for your comments! We have reverted the XYPlot.java and updated the pr title&description. Could you please approve this pr? |
Hi,
We find that there exist container inefficiency in FlowArrangement.java.
In FlowArrangement.java, the List object
itemsInRow
only performs add, clear, and isEmpty operations.And the objects in this list are never accessed.
Therefore, we can replace this list with a boolean variable.
We discovered the above container inefficiency using our tool cinst. The patch is submitted.
Could you please check and accept it? We have tested the patch on our PC. The patched program works well.