Thanks for the feedback!

I've reduced the patch to those spots where I'm adding real value to the
code. 

Please review.
The patch is a lot shorter now...

- Juraj


On Tue, 2008-01-08 at 22:34 -0500, Miguel de Icaza wrote:
> > I don't like to change working code unnecessarily just for your
> > preference. I'd wait for another patch that removes any extra changes.
> 
> I agree with Atsushi's statement, and also:
> 
> > Personally I like as operator which sometimes makes the sources
> > more readable and kind enough for code completion depending on
> > the editor/IDE.
> 
> miguel.
> _______________________________________________
> Mono-devel-list mailing list
> Mono-devel-list@lists.ximian.com
> http://lists.ximian.com/mailman/listinfo/mono-devel-list
> 
Index: System.Collections/ChangeLog
===================================================================
--- System.Collections/ChangeLog	(revision 92431)
+++ System.Collections/ChangeLog	(working copy)
@@ -1,3 +1,9 @@
+2008-01-08  Juraj Skripsky  <[EMAIL PROTECTED]>
+
+	* SortedList.cs (Clone): Remove unnecessary cast with "as".
+
+	* Comparer.cs (Compare): Eliminate "is" check.
+
 2007-11-06  Jb Evain  <[EMAIL PROTECTED]>
 
 	* Hashtable.cs: Don't compare user keys against the special removed
Index: System.Collections/SortedList.cs
===================================================================
--- System.Collections/SortedList.cs	(revision 92431)
+++ System.Collections/SortedList.cs	(working copy)
@@ -1140,7 +1140,7 @@
 			public override object Clone ()
 			{
 				lock (host.SyncRoot) {
-					return (host.Clone () as SortedList);
+					return host.Clone ();
 				}
 			}
 
Index: System.Collections/Comparer.cs
===================================================================
--- System.Collections/Comparer.cs	(revision 92431)
+++ System.Collections/Comparer.cs	(working copy)
@@ -87,10 +87,12 @@
 					return m_compareInfo.Compare (sa, sb);
 			}
 
-			if (a is IComparable)
-				return (a as IComparable).CompareTo (b);
-			else if (b is IComparable)
-				return -(b as IComparable).CompareTo (a);
+			IComparable ca = a as IComparable;
+			if (ca != null)
+				return ca.CompareTo (b);
+			IComparable cb = b as IComparable;
+			if (cb != null)
+				return -cb.CompareTo (a);
 
 			throw new ArgumentException (Locale.GetText ("Neither 'a' nor 'b' implements IComparable."));
 		}
Index: System.Collections.ObjectModel/Collection.cs
===================================================================
--- System.Collections.ObjectModel/Collection.cs	(revision 92431)
+++ System.Collections.ObjectModel/Collection.cs	(working copy)
@@ -51,10 +51,8 @@
 		
 		public Collection ()
 		{
-			List <T> l = new List <T> ();
-			IList l2 = l as IList;
-			syncRoot = l2.SyncRoot;
-			list = l;
+			list = new List <T> ();
+			syncRoot = ((IList)list).SyncRoot;
 		}
 
 		public Collection (IList <T> list)
Index: System.Collections.ObjectModel/ChangeLog
===================================================================
--- System.Collections.ObjectModel/ChangeLog	(revision 92431)
+++ System.Collections.ObjectModel/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2008-01-08  Juraj Skripsky  <[EMAIL PROTECTED]>
+
+	* Collection.cs (.ctor): Replace "as" with explicit cast, as List <T>
+	always implements IList.
+
 2006-08-08  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
 	* ReadOnlyCollection.cs : added get_IList<T>.this(int).
Index: System.Text/EncoderExceptionFallback.cs
===================================================================
--- System.Text/EncoderExceptionFallback.cs	(revision 92431)
+++ System.Text/EncoderExceptionFallback.cs	(working copy)
@@ -49,7 +49,7 @@
 
 		public override bool Equals (object value)
 		{
-			return value as EncoderExceptionFallback != null;
+			return (value is EncoderExceptionFallback);
 		}
 
 		public override int GetHashCode ()
Index: System.Text/ChangeLog
===================================================================
--- System.Text/ChangeLog	(revision 92431)
+++ System.Text/ChangeLog	(working copy)
@@ -1,3 +1,8 @@
+2008-01-08  Juraj Skripsky  <[EMAIL PROTECTED]>
+
+	* EncoderExceptionFallback.cs (Equals),
+	DecoderExceptionFallback.cs (Equals): Reduce ".. as .. != null" to "is".
+	
 2007-12-27  Atsushi Enomoto  <[EMAIL PROTECTED]>
 
 	* DecoderFallback.cs, EncoderFallback.cs, Encoding.cs :
Index: System.Text/DecoderExceptionFallback.cs
===================================================================
--- System.Text/DecoderExceptionFallback.cs	(revision 92431)
+++ System.Text/DecoderExceptionFallback.cs	(working copy)
@@ -49,7 +49,7 @@
 
 		public override bool Equals (object value)
 		{
-			return value as DecoderExceptionFallback != null;
+			return (value is DecoderExceptionFallback);
 		}
 
 		public override int GetHashCode ()
Index: System.Runtime.Remoting.Proxies/ChangeLog
===================================================================
--- System.Runtime.Remoting.Proxies/ChangeLog	(revision 92431)
+++ System.Runtime.Remoting.Proxies/ChangeLog	(working copy)
@@ -1,3 +1,7 @@
+2008-01-08  Juraj Skripsky  <[EMAIL PROTECTED]>
+
+	* RealProxy.cs (PrivateInvoke): Optimize by eliminating two "as" casts.
+
 2007-05-03  Dick Porter  <[EMAIL PROTECTED]>
 
 	* ProxyAttribute.cs: 
Index: System.Runtime.Remoting.Proxies/RealProxy.cs
===================================================================
--- System.Runtime.Remoting.Proxies/RealProxy.cs	(revision 92431)
+++ System.Runtime.Remoting.Proxies/RealProxy.cs	(working copy)
@@ -162,7 +162,7 @@
 			MonoMethodMessage mMsg = (MonoMethodMessage) msg;
 			mMsg.LogicalCallContext = CallContext.CreateLogicalCallContext (true);
 			CallType call_type = mMsg.CallType;
-			bool is_remproxy = (rp as RemotingProxy) != null;
+			RemotingProxy remproxy = (rp as RemotingProxy);
 
 			IMethodReturnMessage res_msg = null;
 			
@@ -176,8 +176,8 @@
 			// Check for constructor msg
 			if (mMsg.MethodBase.IsConstructor) 
 			{
-				if (is_remproxy) 
-					res_msg = (IMethodReturnMessage) (rp as RemotingProxy).ActivateRemoteObject ((IMethodMessage) msg);
+				if (remproxy != null) 
+					res_msg = (IMethodReturnMessage)remproxy.ActivateRemoteObject ((IMethodMessage) msg);
 				else 
 					msg = new ConstructionCall (rp.GetProxiedType ());
 			}
@@ -190,12 +190,12 @@
 				// checking if it was a remoting or custom proxy, but in some
 				// cases the remoting proxy finish before the call returns
 				// causing this method to be called, therefore causing all kind of bugs.
-				if ((!is_remproxy) && call_type == CallType.BeginInvoke)
+				if ((remproxy == null) && call_type == CallType.BeginInvoke)
 				{
 					IMessage asyncMsg = null;
 
 					// allow calltype EndInvoke to finish
-					asyncMsg = mMsg.AsyncResult.SyncProcessMessage (res_msg as IMessage);
+					asyncMsg = mMsg.AsyncResult.SyncProcessMessage (res_msg);
 					res_msg = new ReturnMessage (asyncMsg, null, 0, null, res_msg as IMethodCallMessage);
 				}
 			}
_______________________________________________
Mono-devel-list mailing list
Mono-devel-list@lists.ximian.com
http://lists.ximian.com/mailman/listinfo/mono-devel-list

Reply via email to