Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/mono/mono.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
path: root/mcs
diff options
context:
space:
mode:
authorZoltan Varga <vargaz@gmail.com>2013-03-24 06:33:24 +0400
committerZoltan Varga <vargaz@gmail.com>2013-03-24 06:33:24 +0400
commitadc5d247ef609b4ce3f1bdaa665df60359cae613 (patch)
treee6d5b332b149d2dd069ca1319e1a873b6b20a847 /mcs
parent6dbaf9b6719ed31c915e9d61303fdaf527cc4af2 (diff)
Use (uint) casts in the Marshal.Read/WriteXXX () methods to speed up the alignment checks.
Diffstat (limited to 'mcs')
-rw-r--r--mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs12
1 files changed, 6 insertions, 6 deletions
diff --git a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
index ccda8115b16..cdb5ab11737 100644
--- a/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
+++ b/mcs/class/corlib/System.Runtime.InteropServices/Marshal.cs
@@ -727,7 +727,7 @@ namespace System.Runtime.InteropServices
{
// The mono JIT can't inline this due to the hight number of calls
// return ReadInt16 (ptr, 0);
- if (ptr.ToInt32 () % 2 == 0) {
+ if ((uint)ptr % 2 == 0) {
unsafe {
return *(short*)ptr;
}
@@ -764,7 +764,7 @@ namespace System.Runtime.InteropServices
[ReliabilityContractAttribute (Consistency.WillNotCorruptState, Cer.Success)]
public static int ReadInt32 (IntPtr ptr)
{
- if (ptr.ToInt32 () % 4 == 0) {
+ if ((uint)ptr % 4 == 0) {
unsafe {
return *(int*)ptr;
}
@@ -805,7 +805,7 @@ namespace System.Runtime.InteropServices
{
// The real alignment might be 4 on some platforms, but this is just an optimization,
// so it doesn't matter.
- if (ptr.ToInt32 () % 8 == 0) {
+ if ((uint)ptr % 8 == 0) {
unsafe {
return *(long*)ptr;
}
@@ -1105,7 +1105,7 @@ namespace System.Runtime.InteropServices
public static void WriteInt16 (IntPtr ptr, short val)
{
- if (ptr.ToInt32 () % 2 == 0) {
+ if ((uint)ptr % 2 == 0) {
unsafe {
*(short*)ptr = val;
}
@@ -1152,7 +1152,7 @@ namespace System.Runtime.InteropServices
public static void WriteInt32 (IntPtr ptr, int val)
{
- if (ptr.ToInt32 () % 4 == 0) {
+ if ((uint)ptr % 4 == 0) {
unsafe {
*(int*)ptr = val;
}
@@ -1185,7 +1185,7 @@ namespace System.Runtime.InteropServices
public static void WriteInt64 (IntPtr ptr, long val)
{
// See ReadInt64 ()
- if (ptr.ToInt32 () % 8 == 0) {
+ if ((uint)ptr % 8 == 0) {
unsafe {
*(long*)ptr = val;
}