2009-11-30 Sebastien Pouliot <sebastien@ximian.com>
authorSebastien Pouliot <sebastien@ximian.com>
Tue, 1 Dec 2009 02:07:06 +0000 (02:07 -0000)
committerSebastien Pouliot <sebastien@ximian.com>
Tue, 1 Dec 2009 02:07:06 +0000 (02:07 -0000)
* CookieCollection.cs: Seal inner CookieCollectionPathComparer
* IPAddress.cs: Avoid multiple casts in Equals
* SocketAddress.cs: Avoid multiple casts in Equals
[Found using Gendarme]

svn path=/trunk/mcs/; revision=147163

mcs/class/System/System.Net/ChangeLog
mcs/class/System/System.Net/CookieCollection.cs
mcs/class/System/System.Net/IPAddress.cs
mcs/class/System/System.Net/SocketAddress.cs

index 978f54a44acb116ea729a0ac36335539283726ef..c50836cbe13cfecd18e6434d88aa1534ee08a291 100644 (file)
@@ -1,3 +1,10 @@
+2009-11-30  Sebastien Pouliot  <sebastien@ximian.com>
+
+       * CookieCollection.cs: Seal inner CookieCollectionPathComparer
+       * IPAddress.cs: Avoid multiple casts in Equals
+       * SocketAddress.cs: Avoid multiple casts in Equals
+       [Found using Gendarme]
+
 2009-10-23  Alexandre Gomes  <alexmipego@gmail.com>
 
        * WebClient.cs: Fixed GetWebRequest overriding problems, bug: 
index b2ddafba9991237ed08cf8963dd6e2fa1a49eae4..4c5b30f6d5f5248e40f84dc2e26d9f4d72de1146 100644 (file)
@@ -42,7 +42,7 @@ namespace System.Net
 #else
        public class CookieCollection : ICollection, IEnumerable {
 #endif
-               class CookieCollectionPathComparer : IComparer
+               sealed class CookieCollectionPathComparer : IComparer
                {
                        int IComparer.Compare (object p1, object p2)
                        {
index eddb6de39908367d06a8e16fbdacece204ad3ae0..a375eaa7baf2d9e832ddf445b2c73e6af5afee15 100644 (file)
@@ -455,9 +455,8 @@ namespace System.Net {
                /// </returns>
                public override bool Equals (object other)
                {
-                       if (other is System.Net.IPAddress){
-                               IPAddress otherAddr = other as IPAddress;
-
+                       IPAddress otherAddr = other as IPAddress;
+                       if (otherAddr != null){
                                if(AddressFamily != otherAddr.AddressFamily)
                                        return false;
 
index c85941e1647a58d73317996626208e2a05e40058..e410ea79a971a8d68f33a30abc4429b356b3cbca 100644 (file)
@@ -96,9 +96,9 @@ namespace System.Net {
 
                public override bool Equals (object obj)
                {
-                       if (obj is System.Net.SocketAddress &&
-                           ((System.Net.SocketAddress) obj).data.Length == data.Length){
-                               byte [] otherData = ((System.Net.SocketAddress) obj).data;
+                       SocketAddress sa = (obj as SocketAddress);
+                       if ((sa != null) && (sa.data.Length == data.Length)) {
+                               byte [] otherData = sa.data;
                                for (int i = 0; i < data.Length; i++)
                                        if (otherData [i] != data [i])
                                                return false;