Skip to content

Refactor Transform nested types to remove inner class boilerplate#3221

Merged
HeikoKlare merged 1 commit intoeclipse-platform:masterfrom
HeikoKlare:cleanup/transform-simplification
Apr 11, 2026
Merged

Refactor Transform nested types to remove inner class boilerplate#3221
HeikoKlare merged 1 commit intoeclipse-platform:masterfrom
HeikoKlare:cleanup/transform-simplification

Conversation

@HeikoKlare
Copy link
Copy Markdown
Contributor

@HeikoKlare HeikoKlare commented Apr 10, 2026

Summary

This PR cleans up the Win32 Transform class by eliminating unnecessary boilerplate in its private nested types and a few helper methods.

Changes

Inner classes converted to static nested types

SetElementsOperation and TranslateOperation were non-static inner classes, causing them to hold an implicit reference to the enclosing Transform instance. They are now records with the Drawable device passed explicitly as a constructor argument, making the dependency visible and breaking the implicit outer-instance capture. MultiplyOperation was converted to a static nested class for the same reason, since it already uses a float[] field which makes it unsuitable for a record.

Removal of local variable aliases

Several apply() implementations introduced unnecessary local variables like long handle = transformHandle.handle or int zoom = transformHandle.zoom. These have been removed in favour of direct field access on the record, reducing noise without any semantic change.

Extracted destroyAllHandles() helper

destroy() and destroyHandlesExcept() contained identical two-line sequences to iterate and clear zoomToHandle. This is now delegated to a private destroyAllHandles() method.

getTransformHandle() simplified with computeIfAbsent

The previous containsKey / get / put pattern performing three map lookups was replaced with a single Map.computeIfAbsent() call.

Lambda simplification in isIdentity()

A single-expression block lambda was collapsed into an expression lambda.

Variable naming in newTransformHandle()

A local variable named newTransformHandle shadowed the method of the same name. It has been renamed to transformHandle for clarity.


This PR was created with the help of GitHub Copilot.

Convert SetElementsOperation and TranslateOperation from non-static
inner classes to records, making their dependency on the device
explicit via a constructor parameter rather than capturing the outer
instance implicitly. Make MultiplyOperation a static nested class for
the same reason.

Also extract a destroyAllHandles() helper to eliminate duplicated code,
simplify getTransformHandle() with Map.computeIfAbsent(), collapse a
single-expression block lambda in isIdentity(), and remove unnecessary
local handle aliases inside the operation apply() methods.

Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>
@github-actions
Copy link
Copy Markdown
Contributor

Test Results (win32)

   28 files  ±0     28 suites  ±0   4m 44s ⏱️ +8s
4 653 tests ±0  4 580 ✅ ±0  73 💤 ±0  0 ❌ ±0 
1 187 runs  ±0  1 163 ✅ ±0  24 💤 ±0  0 ❌ ±0 

Results for commit c629f93. ± Comparison against base commit 16e501f.

@HeikoKlare HeikoKlare merged commit 188aed6 into eclipse-platform:master Apr 11, 2026
18 checks passed
@HeikoKlare HeikoKlare deleted the cleanup/transform-simplification branch April 11, 2026 11: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.

1 participant