Skip to content

Commit 1b731c0

Browse files
committed
Reduce useless Point creation
Calling methods with method(new Point(x,y)) when there is an override method(x,y) that is simply called by the former one just generates noise.
1 parent 09ef68c commit 1b731c0

31 files changed

Lines changed: 92 additions & 92 deletions

File tree

bundles/org.eclipse.swt/Eclipse SWT Custom Widgets/common/org/eclipse/swt/custom/CTabFolder.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2020 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -3911,8 +3911,7 @@ boolean updateItems (int showIndex) {
39113911
setButtonBounds();
39123912
changed |= chevronChanged;
39133913
if (changed && getToolTipText() != null) {
3914-
Point pt = getDisplay().getCursorLocation();
3915-
pt = toControl(pt);
3914+
Point pt = toControl(getDisplay().getCursorLocation());
39163915
_setToolTipText(pt.x, pt.y);
39173916
}
39183917
gc.dispose();

bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/common/org/eclipse/swt/dnd/DropTargetEffect.java

Lines changed: 3 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2007, 2008 IBM Corporation and others.
2+
* Copyright (c) 2007, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -97,8 +97,7 @@ public Widget getItem(int x, int y) {
9797
}
9898

9999
Widget getItem(Table table, int x, int y) {
100-
Point coordinates = new Point(x, y);
101-
coordinates = table.toControl(coordinates);
100+
Point coordinates = table.toControl(x, y);
102101
TableItem item = table.getItem(coordinates);
103102
if (item != null) return item;
104103
Rectangle area = table.getClientArea();
@@ -116,8 +115,7 @@ Widget getItem(Table table, int x, int y) {
116115
}
117116

118117
Widget getItem(Tree tree, int x, int y) {
119-
Point point = new Point(x, y);
120-
point = tree.toControl(point);
118+
Point point = tree.toControl(x, y);
121119
TreeItem item = tree.getItem(point);
122120
if (item == null) {
123121
Rectangle area = tree.getClientArea();

bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TableDropTargetEffect.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2025 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -135,8 +135,7 @@ public void dragOver(DropTargetEvent event) {
135135
Table table = (Table) control;
136136
long handle = table.handle;
137137
int effect = checkEffect(event.feedback);
138-
Point coordinates = new Point(event.x, event.y);
139-
coordinates = table.toControl(coordinates);
138+
Point coordinates = table.toControl(event.x, event.y);
140139
long [] path = new long [1];
141140
GTK.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null);
142141
int index = -1;

bundles/org.eclipse.swt/Eclipse SWT Drag and Drop/gtk/org/eclipse/swt/dnd/TreeDropTargetEffect.java

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2025 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -149,8 +149,7 @@ public void dragOver(DropTargetEvent event) {
149149
int effect = checkEffect(event.feedback);
150150

151151
long handle = tree.handle;
152-
Point coordinates = new Point(event.x, event.y);
153-
coordinates = tree.toControl(coordinates);
152+
Point coordinates = tree.toControl(event.x, event.y);
154153
long [] path = new long [1];
155154
GTK.gtk_tree_view_get_path_at_pos (handle, coordinates.x, coordinates.y, path, null, null, null);
156155
int index = -1;

bundles/org.eclipse.swt/Eclipse SWT/emulated/coolbar/org/eclipse/swt/widgets/CoolBar.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2016 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -330,7 +330,7 @@ boolean insertItemIntoRow(CoolItem item, int rowIndex, int x_root) {
330330
Rectangle bounds = items[rowIndex][0].internalGetBounds();
331331
int rowY = bounds.y;
332332
int oldRowHeight = bounds.height;
333-
int x = Math.max(0, Math.abs(x_root - toDisplay(new Point(0, 0)).x));
333+
int x = Math.max(0, Math.abs(x_root - toDisplay(0, 0).x));
334334

335335
/* Find the insertion index and add the item. */
336336
int index;
@@ -604,7 +604,7 @@ void onMouseMove(Event event) {
604604
fixEvent(event);
605605
CoolItem grabbed = getGrabbedItem(event.x, event.y);
606606
if (dragging != null) {
607-
int left_root = toDisplay(new Point(event.x - itemXOffset, event.y)).x;
607+
int left_root = toDisplay(event.x - itemXOffset, event.y).x;
608608
Rectangle bounds = dragging.internalGetBounds();
609609
if (event.y < bounds.y) {
610610
moveUp(dragging, left_root);

examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/CoolBarTab.java

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2025 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -383,7 +383,7 @@ public void widgetSelected(SelectionEvent event) {
383383
final ToolBar toolBar = toolItem.getParent();
384384

385385
Rectangle toolItemBounds = toolItem.getBounds();
386-
Point point = toolBar.toDisplay(new Point(toolItemBounds.x, toolItemBounds.y));
386+
Point point = toolBar.toDisplay(toolItemBounds.x, toolItemBounds.y);
387387
menu.setLocation(point.x, point.y + toolItemBounds.height);
388388
setMenuVisible(true);
389389
}
@@ -429,7 +429,7 @@ public void widgetSelected(SelectionEvent event) {
429429
CoolItem coolItem = (CoolItem) event.widget;
430430
Rectangle itemBounds = coolItem.getBounds ();
431431
itemBounds.width = event.x - itemBounds.x;
432-
Point pt = coolBar.toDisplay(new Point (itemBounds.x, itemBounds.y));
432+
Point pt = coolBar.toDisplay(itemBounds.x, itemBounds.y);
433433
itemBounds.x = pt.x;
434434
itemBounds.y = pt.y;
435435

@@ -444,7 +444,7 @@ public void widgetSelected(SelectionEvent event) {
444444
int i = 0;
445445
while (i < toolCount) {
446446
Rectangle toolBounds = tools[i].getBounds ();
447-
pt = toolBar.toDisplay(new Point(toolBounds.x, toolBounds.y));
447+
pt = toolBar.toDisplay(toolBounds.x, toolBounds.y);
448448
toolBounds.x = pt.x;
449449
toolBounds.y = pt.y;
450450
Rectangle intersection = itemBounds.intersection (toolBounds);
@@ -490,7 +490,7 @@ public void widgetSelected(SelectionEvent event) {
490490
/* Display the pop-up menu at the lower left corner of the arrow button.
491491
* Dispose the menu when the user is done with it.
492492
*/
493-
pt = coolBar.toDisplay(new Point(event.x, event.y));
493+
pt = coolBar.toDisplay(event.x, event.y);
494494
menu.setLocation (pt.x, pt.y);
495495
menu.setVisible (true);
496496
while (menu != null && !menu.isDisposed() && menu.isVisible ()) {

examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TableTab.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2017 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -784,7 +784,7 @@ void setWidgetLinesVisible () {
784784
protected void specialPopupMenuItems(Menu menu, Event event) {
785785
MenuItem item = new MenuItem(menu, SWT.PUSH);
786786
item.setText("getItem(Point) on mouse coordinates");
787-
menuMouseCoords = table1.toControl(new Point(event.x, event.y));
787+
menuMouseCoords = table1.toControl(event.x, event.y);
788788
item.addSelectionListener(widgetSelectedAdapter(e -> {
789789
eventConsole.append ("getItem(Point(" + menuMouseCoords + ")) returned: " + table1.getItem(menuMouseCoords));
790790
eventConsole.append ("\n");

examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/ToolBarTab.java

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2015 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -378,8 +378,8 @@ public void widgetSelected(SelectionEvent event) {
378378
final ToolItem toolItem = (ToolItem) event.widget;
379379
final ToolBar toolBar = toolItem.getParent();
380380

381-
Point point = toolBar.toDisplay(new Point(event.x, event.y));
382-
menu.setLocation(point.x, point.y);
381+
Point point = toolBar.toDisplay(event.x, event.y);
382+
menu.setLocation(point);
383383
menu.setVisible(true);
384384
}
385385
}

examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/controlexample/TreeTab.java

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2017 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -869,7 +869,7 @@ protected void specialPopupMenuItems(Menu menu, Event event) {
869869
MenuItem item = new MenuItem(menu, SWT.PUSH);
870870
item.setText("getItem(Point) on mouse coordinates");
871871
final Tree t = (Tree) event.widget;
872-
menuMouseCoords = t.toControl(new Point(event.x, event.y));
872+
menuMouseCoords = t.toControl(event.x, event.y);
873873
item.addSelectionListener(widgetSelectedAdapter(e -> {
874874
eventConsole.append ("getItem(Point(" + menuMouseCoords + ")) returned: " + t.getItem(menuMouseCoords));
875875
eventConsole.append ("\n");

examples/org.eclipse.swt.examples/src/org/eclipse/swt/examples/fileviewer/FileViewer.java

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
/*******************************************************************************
2-
* Copyright (c) 2000, 2025 IBM Corporation and others.
2+
* Copyright (c) 2000, 2026 IBM Corporation and others.
33
*
44
* This program and the accompanying materials
55
* are made available under the terms of the Eclipse Public License 2.0
@@ -45,7 +45,6 @@
4545
import org.eclipse.swt.events.TreeAdapter;
4646
import org.eclipse.swt.events.TreeEvent;
4747
import org.eclipse.swt.graphics.Image;
48-
import org.eclipse.swt.graphics.Point;
4948
import org.eclipse.swt.graphics.Rectangle;
5049
import org.eclipse.swt.layout.GridData;
5150
import org.eclipse.swt.layout.GridLayout;
@@ -536,7 +535,7 @@ public void drop(DropTargetEvent event) {
536535
}
537536
private File getTargetFile(DropTargetEvent event) {
538537
// Determine the target File for the drop
539-
TreeItem item = tree.getItem(tree.toControl(new Point(event.x, event.y)));
538+
TreeItem item = tree.getItem(tree.toControl(event.x, event.y));
540539
File targetFile = null;
541540
if (item != null) {
542541
// We are over a particular item in the tree, use the item's file
@@ -845,7 +844,7 @@ public void drop(DropTargetEvent event) {
845844
}
846845
private File getTargetFile(DropTargetEvent event) {
847846
// Determine the target File for the drop
848-
TableItem item = table.getItem(table.toControl(new Point(event.x, event.y)));
847+
TableItem item = table.getItem(table.toControl(event.x, event.y));
849848
File targetFile = null;
850849
if (item == null) {
851850
// We are over an unoccupied area of the table.

0 commit comments

Comments
 (0)