Commit 462dbb3
Simplify and clean up Cursor.java (Win32)
Several small improvements to the Win32 Cursor implementation:
- Replace double map-lookup and setHandleForZoomLevel() helper with a
single HashMap.computeIfAbsent() call in win32_getHandle(). The
helper method contained redundant null/containsKey guards that were
already enforced by the call-site; both are now unnecessary.
- Change win32_getHandle() return type from boxed Long to primitive
long, consistent with Font.win32_getHandle(), Image.win32_getHandle()
and Region.win32_getHandle(). All existing call sites already
consumed the result as a long, so no callers required changes.
- Fix latent equality bug in equals(): the previous code compared two
Long wrapper objects with ==, which only gives correct results for
cached values in [-128, 127]. Cursor handles are OS memory addresses
and fall well outside that range. With the primitive return type the
comparison is now a straightforward == on long values, which is both
correct and avoids boxing.
- Use Java 16+ instanceof pattern matching in equals() to eliminate
the explicit cast after the type check.
- Remove unnecessary clone() in ImageDataWithMaskCursorHandleProvider
.validateMask(): the cloned ImageData was only ever read for its
width/height fields, so the defensive copy was pure overhead.
- Remove redundant 'static' modifier on the nested CursorHandleProvider
interface declaration; nested interfaces are implicitly static.
- Remove redundant 'final' modifier on the private static method
getOSCursorIdFromStyle(); private static methods cannot be overridden.
- Remove redundant 'final' modifier on the lambda-captured local
variable in destroyHandlesExcept(); the variable is effectively final
without the explicit keyword.
Co-authored-by: Copilot <223556219+Copilot@users.noreply.github.com>1 parent 16e501f commit 462dbb3
File tree
1 file changed
+14
-26
lines changed- bundles/org.eclipse.swt/Eclipse SWT/win32/org/eclipse/swt/graphics
1 file changed
+14
-26
lines changedLines changed: 14 additions & 26 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
316 | 316 | | |
317 | 317 | | |
318 | 318 | | |
319 | | - | |
| 319 | + | |
320 | 320 | | |
321 | 321 | | |
322 | 322 | | |
323 | | - | |
324 | | - | |
325 | | - | |
326 | | - | |
327 | | - | |
328 | | - | |
329 | | - | |
330 | | - | |
331 | | - | |
332 | | - | |
333 | | - | |
334 | | - | |
335 | | - | |
336 | | - | |
337 | | - | |
| 323 | + | |
| 324 | + | |
| 325 | + | |
| 326 | + | |
338 | 327 | | |
339 | 328 | | |
340 | 329 | | |
| |||
389 | 378 | | |
390 | 379 | | |
391 | 380 | | |
392 | | - | |
393 | | - | |
| 381 | + | |
394 | 382 | | |
395 | 383 | | |
396 | 384 | | |
| |||
406 | 394 | | |
407 | 395 | | |
408 | 396 | | |
409 | | - | |
| 397 | + | |
410 | 398 | | |
411 | 399 | | |
412 | 400 | | |
| |||
439 | 427 | | |
440 | 428 | | |
441 | 429 | | |
442 | | - | |
| 430 | + | |
443 | 431 | | |
444 | 432 | | |
445 | 433 | | |
| |||
492 | 480 | | |
493 | 481 | | |
494 | 482 | | |
495 | | - | |
| 483 | + | |
496 | 484 | | |
497 | 485 | | |
498 | 486 | | |
| |||
513 | 501 | | |
514 | 502 | | |
515 | 503 | | |
516 | | - | |
| 504 | + | |
517 | 505 | | |
518 | 506 | | |
519 | 507 | | |
| |||
663 | 651 | | |
664 | 652 | | |
665 | 653 | | |
666 | | - | |
667 | | - | |
| 654 | + | |
| 655 | + | |
668 | 656 | | |
669 | 657 | | |
670 | 658 | | |
671 | | - | |
| 659 | + | |
672 | 660 | | |
673 | 661 | | |
674 | | - | |
| 662 | + | |
675 | 663 | | |
676 | 664 | | |
677 | 665 | | |
| |||
0 commit comments