Skip to content

Improve DocLineComparator performance #2575#2576

Closed
mehmet-karaman wants to merge 1 commit intoeclipse-platform:masterfrom
mehmet-karaman:DocLineComparator_2575
Closed

Improve DocLineComparator performance #2575#2576
mehmet-karaman wants to merge 1 commit intoeclipse-platform:masterfrom
mehmet-karaman:DocLineComparator_2575

Conversation

@mehmet-karaman
Copy link
Copy Markdown
Contributor

Add a lightweight preliminary check before invoking String.equals(), which avoids unnecessary overhead while preserving correctness for other comparison cases.

Fixes #2575

@mehmet-karaman mehmet-karaman marked this pull request as draft March 16, 2026 13:01
@mehmet-karaman
Copy link
Copy Markdown
Contributor Author

mehmet-karaman commented Mar 16, 2026

Changed PR to draft, need to fix the test failures org.eclipse.compare.tests

@github-actions
Copy link
Copy Markdown
Contributor

github-actions bot commented Mar 16, 2026

Test Results

    54 files  ±0      54 suites  ±0   36m 53s ⏱️ + 1m 18s
 4 546 tests ±0   4 523 ✅ +1   23 💤 ±0  0 ❌  - 1 
12 234 runs  ±0  12 075 ✅ +1  159 💤 ±0  0 ❌  - 1 

Results for commit 6bc4e2a. ± Comparison against base commit 2222ff6.

♻️ This comment has been updated with latest results.

return linesToCompare[0].equals(linesToCompare[1]);
String s1 = linesToCompare[0];
String s2 = linesToCompare[1];
if (s1.isEmpty() == s2.isEmpty()) {
Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

So two non empty lines are equal?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

How it comes? The first and the second check is just to avoid index out of bounds exceptions..

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Put a breakpoint in the return true new line and run DocLineComparatorTest

Copy link
Copy Markdown
Contributor Author

@mehmet-karaman mehmet-karaman Mar 16, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It is supposed to work only on the positive case :) Going to check this.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Replace "==" by "&&".

Add a lightweight preliminary check before invoking String.equals(),
which avoids unnecessary overhead while preserving correctness
for other comparison cases.

Fixes eclipse-platform#2575
@mehmet-karaman mehmet-karaman force-pushed the DocLineComparator_2575 branch from 85a4a63 to 6bc4e2a Compare March 23, 2026 22:05
@mehmet-karaman
Copy link
Copy Markdown
Contributor Author

Closing this PR, it seems that this is only a micro optimization in the whole compare algorithm.

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.

DocLineComparator performance issue

3 participants