changeset 29:e6843df719a8

Use scope when creating EventArgs to avoid unnecessary heap usage.
author Jordan Miner <jminer7@gmail.com>
date Sat, 25 Jul 2009 15:25:38 -0500
parents 00efca2c1545
children 545af935f201
files dynamin/gui/windows_window.d
diffstat 1 files changed, 9 insertions(+), 6 deletions(-) [+]
line wrap: on
line diff
--- a/dynamin/gui/windows_window.d	Sat Jul 25 15:14:00 2009 -0500
+++ b/dynamin/gui/windows_window.d	Sat Jul 25 15:25:38 2009 -0500
@@ -756,8 +756,8 @@
 		int delta = -cast(short)HIWORD(wParam);
 		auto screenPt = Point(LOWORD(lParam), HIWORD(lParam));
 		auto des = c.getDescendantAtPoint(c.screenToContent(screenPt));
-		des.mouseTurned(
-			new MouseTurnedEventArgs(delta, delta*scrollLines/120.0) );
+		scope args = new MouseTurnedEventArgs(delta, delta*scrollLines/120.0);
+		des.mouseTurned(args);
 		return 0;
 	case WM_SYSKEYDOWN:
 		//Stdout.format("WM_SYSKEYDOWN: {:x}", cast(int)wParam).newline;
@@ -766,8 +766,9 @@
 	case WM_KEYDOWN:
 		//Stdout.format("WM_KEYDOWN:    {:x}", cast(int)wParam).newline;
 		Control focused = c.focusedControl ? c.focusedControl : c;
-		focused.keyDown(new KeyEventArgs(
-			VKToKey(wParam), cast(bool)(lParam & (1 << 30)) ));
+		scope args = new KeyEventArgs(
+			VKToKey(wParam), cast(bool)(lParam & (1 << 30)) );
+		focused.keyDown(args);
 		return 0;
 	case WM_SYSKEYUP:
 		//Stdout.format("WM_SYSKEYUP: {:x}", cast(int)wParam).newline;
@@ -776,7 +777,8 @@
 	case WM_KEYUP:
 		//Stdout.format("WM_KEYUP:    {:x}", cast(int)wParam).newline;
 		Control focused = c.focusedControl ? c.focusedControl : c;
-		focused.keyUp(new KeyEventArgs( VKToKey(wParam), false ));
+		scope args = new KeyEventArgs( VKToKey(wParam), false );
+		focused.keyUp(args);
 		return 0;
 	case WM_CHAR:
 		// DO NOT use the repeat count from the lParam to send multiple events
@@ -793,7 +795,8 @@
 		bool repeat;
 		repeat = cast(bool)(lParam & (1 << 30));
 		Control focused = c.focusedControl ? c.focusedControl : c;
-		focused.keyTyped(new KeyTypedEventArgs(cast(dchar)wParam, repeat));
+		scope args = new KeyTypedEventArgs(cast(dchar)wParam, repeat);
+		focused.keyTyped(args);
 		return 0;
 	case WM_PRINT:
 		paintToHDC(cast(HDC)wParam, getControl(hwnd), null);