Cache size of char
authorStefanos A <stapostol@gmail.com>
Mon, 9 Dec 2013 22:46:07 +0000 (23:46 +0100)
committerStefanos A <stapostol@gmail.com>
Mon, 9 Dec 2013 22:46:07 +0000 (23:46 +0100)
BlittableValueType<char> caches the size of the type parameter. This
way, we avoid calling Marshal.SizeOf repeatedly for every keyboard
event.

Source/OpenTK/Platform/MacOS/CarbonBindings/CarbonAPI.cs

index be079f9..83c41a4 100644 (file)
@@ -684,9 +684,9 @@ namespace OpenTK.Platform.MacOS.Carbon
                 char* codeAddr = &code;
 
                 OSStatus result = API.GetEventParameter(inEvent,
-                     EventParamName.KeyMacCharCode, EventParamType.typeChar, IntPtr.Zero,
-                     (uint)System.Runtime.InteropServices.Marshal.SizeOf(typeof(char)), IntPtr.Zero,
-                     (IntPtr)codeAddr);
+                    EventParamName.KeyMacCharCode, EventParamType.typeChar, IntPtr.Zero,
+                    (uint)BlittableValueType<char>.Stride, IntPtr.Zero,
+                    (IntPtr)codeAddr);
 
                 if (result != OSStatus.NoError)
                 {