Greatly improve performance of overload resolution, fix various aspects of it

0) Greatly increased performance of the method overload resolution.

1) Redundant code removed from TypeConverter - it does nothing, but strikes performance. Probably some garbage left after refactoring/restructurization.

2) NullReferenceException in TypeConverter.FindBestMatch when trying to find overload to invoke with null-argument.

3) AmbiguousMatchException in IndexDescriptor.ctor when class has multiple public indexers. Also get rid of inconsistency of working with getters and setters separately (i.e. read from one, write to another).
I saw that, still, the first read is not locked, so this one AND the write can happen concurrently, and dictionary is not thead safe. Even two reads are not so the whole thing has to be locked, thus removing one of the reads. The other solution is to not make the cache static, but that limits the efficiency.

-----Original Message-----
From: "h15ter" <notifications@github.com>
Sent: ‎9/‎25/‎2014 4:10 AM
To: "sebastienros/jint" <jint@noreply.github.com>
Cc: "Sébastien Ros" <sebastienros@gmail.com>
Subject: Re: [jint] Greatly improve performance of overload resolution, fixvarious aspects of it (#77)

In Jint/Runtime/Interop/DefaultTypeConverter.cs:
> @@ -25,5 +30,42 @@ public object Convert(object value, Type type, IFormatProvider formatProvider)
>  
>              return System.Convert.ChangeType(value, type, formatProvider);
>          }
> +
> +        public bool TryConvert(object value, Type type, IFormatProvider formatProvider, out object converted)
> +        {
> +            bool canConvert;
> +            var key = value == null ? String.Format("Null->{0}", type) : String.Format("{0}->{1}", value.GetType(), type);
> +
> +            if (!KnownConversions.TryGetValue(key, out canConvert))
> +            {
> +                lock (LockObject)
The lock is double-checked (before and after) to avoid unnecessary locking.
—
Reply to this email directly or view it on GitHub.=