Browse Source

* namespace.cs (NamespaceLookupType): Avoid a string allocation when we
already found a typebuilder.
* class.cs (MethodCore.IsDuplicateImplementation): Compare
MemberNames, not strings.

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

Raja R Harinath 20 years ago
parent
commit
ab8fa5ac74
3 changed files with 16 additions and 12 deletions
  1. 5 0
      mcs/mcs/ChangeLog
  2. 7 11
      mcs/mcs/class.cs
  3. 4 1
      mcs/mcs/namespace.cs

+ 5 - 0
mcs/mcs/ChangeLog

@@ -1,5 +1,10 @@
 2005-07-21  Raja R Harinath  <[email protected]>
 
+	* namespace.cs (NamespaceLookupType): Avoid a string allocation when we
+	already found a typebuilder.
+	* class.cs (MethodCore.IsDuplicateImplementation): Compare
+	MemberNames, not strings.
+
 	* const.cs (Error_ExpressionMustBeConst): 
 	Rename from Error_EpressionMustBeConst.
 	* const.cs, class.cs, statement.cd: Update.

+ 7 - 11
mcs/mcs/class.cs

@@ -3461,11 +3461,13 @@ namespace Mono.CSharp {
 
 		protected bool IsDuplicateImplementation (MethodCore method)
 		{
-			if ((method == this) || (method.Name != Name))
+			if (method == this || !(method.MemberName.Equals (MemberName)))
 				return false;
 
 			Type[] param_types = method.ParameterTypes;
-			if (param_types == null)
+			if (param_types == null && ParameterTypes == null)
+				return true;
+			if (param_types == null || ParameterTypes == null)
 				return false;
 
 			if (param_types.Length != ParameterTypes.Length)
@@ -3503,14 +3505,8 @@ namespace Mono.CSharp {
 			return true;
 		}
 
-		public override bool IsUsed
-		{
-			get {
-				if (IsExplicitImpl)
-					return true;
-
-				return base.IsUsed;
-			}
+		public override bool IsUsed {
+			get { return IsExplicitImpl || base.IsUsed; }
 		}
 
 		//
@@ -5839,7 +5835,7 @@ namespace Mono.CSharp {
 
 		public bool IsDuplicateImplementation (MethodCore method)
 		{
-			if (Name != method.Name)
+			if (!MemberName.Equals (method.MemberName))
 				return false;
 
 			Type[] param_types = method.ParameterTypes;

+ 4 - 1
mcs/mcs/namespace.cs

@@ -66,6 +66,9 @@ namespace Mono.CSharp {
 			else
 				fullname = parent.Name + "." + name;
 
+			if (fullname == null)
+				throw new InternalErrorException ("Namespace has a null fullname");
+
 			if (parent != null && parent.MemberName != MemberName.Null)
 				MemberName = new MemberName (parent.MemberName, name);
 			else if (name == "")
@@ -155,7 +158,7 @@ namespace Mono.CSharp {
 				tdecl.DefineType ();
 				t = tdecl.TypeBuilder;
 			}
-			string lookup = this == Namespace.Root ? name : fullname + "." + name;
+			string lookup = t != null ? t.FullName : (fullname == "" ? name : fullname + "." + name);
 			Type rt = TypeManager.LookupTypeReflection (lookup);
 			if (t == null)
 				t = rt;