Skip to content

TargetPlatformHelper.java - Performance & Readability Improvements#2060

Merged
vogella merged 2 commits intoeclipse-pde:masterfrom
vogella:target-platform-helper
Dec 3, 2025
Merged

TargetPlatformHelper.java - Performance & Readability Improvements#2060
vogella merged 2 commits intoeclipse-pde:masterfrom
vogella:target-platform-helper

Conversation

@vogella
Copy link
Contributor

@vogella vogella commented Oct 25, 2025

Optimizations:

  • Line 97: Added precompiled PATTERN_PATH_COLON regex pattern to avoid repeated compilation in stripPathInformation() method
  • Line 170: Changed from replaceAll() with string regex (which recompiles pattern each time) to using the precompiled pattern - significant performance
    improvement in hot paths
  • Line 327: Modernized array creation using method reference String[]::new instead of new String[result.size()]
  • Line 423-450: Refactored getTargetVersionString() method to use modern switch expression, reducing from 26 lines with repetitive if-statements to 14 lines -
    much cleaner and more maintainable
  • Line 623-627: Simplified getFeaturePaths() to use streams instead of manual list iteration - more functional and readable
  • Line 703-709: Improved thread-safety of addTargetDefinitionMap() by making it synchronized and using computeIfAbsent() to eliminate race conditions and
    simplify logic

Impact:

  • Reduced regex compilation overhead in path processing
  • Better thread safety for cached data
  • Improved code readability with modern Java patterns
  • No API changes - all improvements are internal

@vogella
Copy link
Contributor Author

vogella commented Oct 25, 2025

I assume the build will fail (PDE build is currently not working), so I plan to leave this here and return to it, once PDE build are green again.


private static Map<String, String> fgCachedLocations;
private static Map<ITargetHandle, List<TargetDefinition>> fgCachedTargetDefinitionMap = new HashMap<>();
// Use concurrent map to avoid synchronization overhead on read operations
Copy link
Member

Choose a reason for hiding this comment

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

comment doesn't match code

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Fixed

}
}
return list.toArray(new String[list.size()]);
return Arrays.stream(models)
Copy link
Member

Choose a reason for hiding this comment

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

This is highly questionable, as it makes no improvement functionally, and makes debugging impossible.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Changed back

@github-actions
Copy link

github-actions bot commented Oct 25, 2025

Test Results

   771 files  ±0     771 suites  ±0   1h 3m 16s ⏱️ + 8m 4s
 3 648 tests ±0   3 594 ✅ ±0   54 💤 ±0  0 ❌ ±0 
10 878 runs  ±0  10 715 ✅ ±0  163 💤 ±0  0 ❌ ±0 

Results for commit e6f13ec. ± Comparison against base commit 6a28c28.

♻️ This comment has been updated with latest results.

@vogella vogella force-pushed the target-platform-helper branch from f57d3be to e4cac57 Compare November 2, 2025 11:53
Optimized regex pattern compilation by precompiling PATTERN_PATH_COLON
pattern used in stripPathInformation() method. Simplified switch
expression in getTargetVersionString() and improved thread-safety in
addTargetDefinitionMap() using computeIfAbsent().

🤖 Generated with [Claude Code](https://claude.com/claude-code)

Co-Authored-By: Claude <noreply@anthropic.com>
@vogella vogella force-pushed the target-platform-helper branch from e4cac57 to bbb9f65 Compare December 3, 2025 12:00
@eclipse-pde-bot
Copy link
Contributor

This pull request changes some projects for the first time in this development cycle.
Therefore the following files need a version increment:

ui/org.eclipse.pde.core/META-INF/MANIFEST.MF

An additional commit containing all the necessary changes was pushed to the top of this PR's branch. To obtain these changes (for example if you want to push more changes) either fetch from your fork or apply the git patch.

Git patch
From 3a64577c1452ca4ee4c0cf74dea6f2627e181b2d Mon Sep 17 00:00:00 2001
From: Eclipse PDE Bot <pde-bot@eclipse.org>
Date: Wed, 3 Dec 2025 12:07:44 +0000
Subject: [PATCH] Version bump(s) for 4.39 stream


diff --git a/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF b/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
index a83a7c3f04..d1d5acc8e3 100644
--- a/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
+++ b/ui/org.eclipse.pde.core/META-INF/MANIFEST.MF
@@ -2,7 +2,7 @@ Manifest-Version: 1.0
 Bundle-ManifestVersion: 2
 Bundle-Name: %name
 Bundle-SymbolicName: org.eclipse.pde.core; singleton:=true
-Bundle-Version: 3.21.100.qualifier
+Bundle-Version: 3.21.200.qualifier
 Bundle-Activator: org.eclipse.pde.internal.core.PDECore
 Bundle-Vendor: %provider-name
 Bundle-Localization: plugin
-- 
2.51.2

Further information are available in Common Build Issues - Missing version increments.

@vogella vogella merged commit ca484e5 into eclipse-pde:master Dec 3, 2025
19 checks passed
@vogella vogella deleted the target-platform-helper branch December 3, 2025 13:10
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.

3 participants