Skip to content
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

Open
wants to merge 2 commits into
base: master
Choose a base branch
from

Conversation

cinsttool
Copy link

@cinsttool cinsttool commented Aug 8, 2024

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.

@@ -199,7 +199,6 @@ protected Size2D arrangeFN(BlockContainer container, Graphics2D g2,
}
else {
// start new row
Copy link

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?

Copy link
Author

@cinsttool cinsttool Sep 1, 2024

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) {
Copy link

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.

Copy link
Author

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.

@cinsttool cinsttool changed the title Fix container inefficiencies in FlowArrangement.java and XYPlot.java Fix container inefficiencies in FlowArrangement.java Sep 4, 2024
@cinsttool cinsttool changed the title Fix container inefficiencies in FlowArrangement.java Fix container inefficiency in FlowArrangement.java Sep 4, 2024
@cinsttool
Copy link
Author

@RockyMM Thank you for your comments!

We have reverted the XYPlot.java and updated the pr title&description.

Could you please approve this pr?

@RockyMM
Copy link

RockyMM commented Sep 6, 2024

@RockyMM Thank you for your comments!

We have reverted the XYPlot.java and updated the pr title&description.

Could you please approve this pr?

Thanks for your good job. I am sorry I gave you the wrong impression, I am not a contributor to this project. Let's tag @jfree so he takes a look.

@cinsttool
Copy link
Author

Thanks for your good job. I am sorry I gave you the wrong impression, I am not a contributor to this project. Let's tag @jfree so he takes a look.

Oh I see. But thanks for your review again @RockyMM !

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants