Skip to content

Speed up FileSystemResourceManager.resourceForLocation() - #2964

Merged
fedejeanne merged 2 commits into
eclipse-platform:masterfrom
fedejeanne:faster-resource-for-location
Sep 24, 2026
Merged

fedejeanne merged 2 commits into
eclipse-platform:masterfrom
fedejeanne:faster-resource-for-location

Conversation

@fedejeanne

Copy link
Copy Markdown
Member

resourceForLocation(IPath, boolean) loops over all projects. This change only reorders side-effect-free checks inside that loop and stops the loop once no better match is possible. It returns exactly what it returned before.

What changed

  • The two integer comparisons on segment counts now run before IPath.isPrefixOf():
    • segmentsToRemove <= resultProjectPathSegments was already checked before, just after isPrefixOf().
    • segmentsToRemove > location.segmentCount() is new, but in that case isPrefixOf() returns false anyway.
  • The loop stops once a project whose location equals location has been accepted. No other project can match more segments, and the loop only replaces a match with a strictly longer one.

No caching, no API change.

Tests

Existing coverage:

  • FileSystemResourceManagerTest.testContainerFor / testFileFor
  • IWorkspaceRootTest.testGetContainerForLocation / testGetFileForLocation / testBug476585
  • FilteredResourceTest.test343914

New tests in IWorkspaceRootTest cover:

  • a project's own location
  • locations outside all projects
  • a project name that is a plain string prefix of another (p / p2)
  • nested projects in both iteration orders, including the nested project's own location
  • filtered resources in nested projects
  • hidden projects

The new tests pass against both the old and the new implementation.

🤖 Generated with Claude Code

Check the cheap segment counts before the more expensive
IPath.isPrefixOf() and stop iterating over the projects as soon as a
project location equal to the given location has been matched, since no
other project can provide a better match.

Add tests covering project locations, nested projects in both iteration
orders, filtered resources in nested projects, hidden projects and
project names being plain string prefixes of each other.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>

Copilot AI left a comment

Copy link
Copy Markdown

Choose a reason for hiding this comment

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

Copilot review overview

🟡 Changes recommended

Both changed plug-ins require service-version updates before approval.

Get a fresh assessment by requesting another Copilot review.

Review effort: Balanced
Findings: 2 High severity

Open (2)
What changed in this PR

Optimizes filesystem location lookup while preserving existing behavior.

Changes:

  • Reorders segment checks and exits after an exact match.
  • Adds regression coverage for location-resolution scenarios.
File Review
resources/​tests/​org.eclipse.core.tests.resources/​src/​org/​eclipse/​core/​tests/​resources/​IWorkspaceRootTest.java Adds regression tests; requires a test plug-in Bundle-Version update.
resources/​bundles/​org.eclipse.core.resources/​src/​org/​eclipse/​core/​internal/​localstore/​FileSystemResourceManager.java Optimizes project matching; requires an implementation bundle Bundle-Version update.

💡 Add a code-review agent skill or configure MCP servers for context-aware, tailored reviews. Learn more in the docs.

@github-actions

github-actions Bot commented Sep 23, 2026 •

Copy link
Copy Markdown
Contributor

Test Results

    54 files  ± 0      54 suites  ±0   58m 43s ⏱️ + 1m 54s
 4 830 tests + 7   4 808 ✅ + 7   22 💤 ±0  0 ❌ ±0 
12 381 runs  +21  12 228 ✅ +21  153 💤 ±0  0 ❌ ±0 

Results for commit bd0b5df. ± Comparison against base commit a439595.

♻️ This comment has been updated with latest results.

Let it match the current version of 'org.eclipse.core.resources',
according to /org.eclipse.platform.docs/VersionNumbering.md (Line 77):
"In particular, a source/test/documentation plug-in that has changes in
the current stream should evolve its version number in sync with the
plug-in(s) it is providing source/test/documentation for."
@fedejeanne
fedejeanne marked this pull request as ready for review September 23, 2026 14:24
@fedejeanne
fedejeanne merged commit ef857d1 into eclipse-platform:master Sep 24, 2026
21 of 22 checks passed
@fedejeanne
fedejeanne deleted the faster-resource-for-location branch September 24, 2026 07:58
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