From: Paolo Molaro Date: Tue, 5 Nov 2013 16:37:08 +0000 (+0100) Subject: Reduce contention and unnecessary checks at each lookup, part of xambug #14644. X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=commitdiff_plain;h=cc7b7992ff4435b177d08072c52956238167d939;p=mono.git Reduce contention and unnecessary checks at each lookup, part of xambug #14644. --- diff --git a/mcs/class/System/System.Net/ServicePointManager.cs b/mcs/class/System/System.Net/ServicePointManager.cs index a6d456293e6..27e9893a80a 100644 --- a/mcs/class/System/System.Net/ServicePointManager.cs +++ b/mcs/class/System/System.Net/ServicePointManager.cs @@ -326,7 +326,8 @@ namespace System.Net if (address == null) throw new ArgumentNullException ("address"); - RecycleServicePoints (); + if ((servicePoints.Count % 4) == 0) + RecycleServicePoints (); var origAddress = new Uri (address.Scheme + "://" + address.Authority); @@ -346,8 +347,8 @@ namespace System.Net address = new Uri (address.Scheme + "://" + address.Authority); ServicePoint sp = null; + SPKey key = new SPKey (origAddress, usesProxy ? address : null, useConnect); lock (servicePoints) { - SPKey key = new SPKey (origAddress, usesProxy ? address : null, useConnect); sp = servicePoints [key] as ServicePoint; if (sp != null) return sp;