Author: abock
Date: 2008-01-24 03:44:24 -0500 (Thu, 24 Jan 2008)
New Revision: 93766
Modified:
trunk/Mono.Zeroconf/src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs
Log:
Use Marshal.ReadByte and bit shift - 4.5x faster than Marshal.Copy - to
construct IP address
Modified:
trunk/Mono.Zeroconf/src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs
===================================================================
---
trunk/Mono.Zeroconf/src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs
2008-01-24 05:58:09 UTC (rev 93765)
+++
trunk/Mono.Zeroconf/src/Mono.Zeroconf.Providers.Bonjour/Mono.Zeroconf.Providers.Bonjour/BrowseService.cs
2008-01-24 08:44:24 UTC (rev 93766)
@@ -129,8 +129,12 @@
break;
}
- byte [] address_raw = new byte[4];
- Marshal.Copy(rdata, address_raw, 0, 4);
+ // ~4.5 times faster than Marshal.Copy into byte[4]
+ uint address_raw = (uint)(Marshal.ReadByte (rdata, 3) <<
24);
+ address_raw |= (uint)(Marshal.ReadByte (rdata, 2) << 16);
+ address_raw |= (uint)(Marshal.ReadByte (rdata, 1) << 8);
+ address_raw |= (uint)Marshal.ReadByte (rdata, 0);
+
IPAddress address = new IPAddress(address_raw);
if(hostentry == null) {
_______________________________________________
Mono-patches maillist - [email protected]
http://lists.ximian.com/mailman/listinfo/mono-patches