From 74df29cff8c0e9f88a5279d60275725935a9db7f Mon Sep 17 00:00:00 2001 From: Ben Maurer Date: Sun, 30 May 2004 23:11:04 +0000 Subject: [PATCH] 2004-05-30 Ben Maurer * convert.cs: add a trivial cache for overload operator resolution. svn path=/trunk/mcs/; revision=28515 --- mcs/mcs/ChangeLog | 4 ++++ mcs/mcs/convert.cs | 11 +++++++++-- 2 files changed, 13 insertions(+), 2 deletions(-) diff --git a/mcs/mcs/ChangeLog b/mcs/mcs/ChangeLog index 08cff8ef83e..42e98f7102d 100755 --- a/mcs/mcs/ChangeLog +++ b/mcs/mcs/ChangeLog @@ -1,3 +1,7 @@ +2004-05-30 Ben Maurer + + * convert.cs: add a trivial cache for overload operator resolution. + 2004-05-31 Marek Safar * attribute.cs diff --git a/mcs/mcs/convert.cs b/mcs/mcs/convert.cs index 7f84d91b2f7..3a743518b31 100644 --- a/mcs/mcs/convert.cs +++ b/mcs/mcs/convert.cs @@ -856,6 +856,8 @@ namespace Mono.CSharp { return UserDefinedConversion (ec, source, target, loc, true); } + static DoubleHash explicit_conv = new DoubleHash (100); + static DoubleHash implicit_conv = new DoubleHash (100); /// /// Computes the MethodGroup for the user-defined conversion /// operators from source_type to target_type. `look_for_explicit' @@ -873,7 +875,10 @@ namespace Mono.CSharp { op_name = "op_Implicit"; MethodGroupExpr union3; - + object r; + if ((look_for_explicit ? explicit_conv : implicit_conv).Lookup (source_type, target_type, out r)) + return (MethodGroupExpr) r; + mg1 = Expression.MethodLookup (ec, source_type, op_name, loc); if (source_type.BaseType != null) mg2 = Expression.MethodLookup (ec, source_type.BaseType, op_name, loc); @@ -922,7 +927,9 @@ namespace Mono.CSharp { union4 = Invocation.MakeUnionSet (union5, union6, loc); } - return Invocation.MakeUnionSet (union3, union4, loc); + MethodGroupExpr ret = Invocation.MakeUnionSet (union3, union4, loc); + (look_for_explicit ? explicit_conv : implicit_conv).Insert (source_type, target_type, ret); + return ret; } /// -- 2.11.4.GIT