}
return true;
+ }\r
+\r
+ public static TypeParameterSpec[] InflateConstraints (TypeParameterInflator inflator, TypeParameterSpec[] tparams)\r
+ {\r
+ return InflateConstraints (tparams, l => l, inflator);\r
}
- public static TypeParameterSpec[] InflateConstraints (TypeParameterInflator inflator, TypeParameterSpec[] tparams)
+ public static TypeParameterSpec[] InflateConstraints<T> (TypeParameterSpec[] tparams, Func<T, TypeParameterInflator> inflatorFactory, T arg)
{
- TypeParameterSpec[] constraints = null;
+ TypeParameterSpec[] constraints = null;\r
+ TypeParameterInflator? inflator = null;
for (int i = 0; i < tparams.Length; ++i) {
var tp = tparams[i];
if (constraints == null) {
constraints = new TypeParameterSpec[tparams.Length];
Array.Copy (tparams, constraints, constraints.Length);
- }
+ }\r
+\r
+ //\r
+ // Using a factory to avoid possibly expensive inflator build up\r
+ //\r
+ if (inflator == null)\r
+ inflator = inflatorFactory (arg);
- constraints[i] = (TypeParameterSpec) constraints[i].InflateMember (inflator);
+ constraints[i] = (TypeParameterSpec) constraints[i].InflateMember (inflator.Value);
}
}
//
public TypeParameterSpec[] Constraints {
get {
- if (constraints == null) {
- var inflator = CreateLocalInflator ();
- constraints = TypeParameterSpec.InflateConstraints (inflator, MemberDefinition.TypeParameters);
+ if (constraints == null) {\r
+ constraints = TypeParameterSpec.InflateConstraints (MemberDefinition.TypeParameters, l => l.CreateLocalInflator (), this);
}
return constraints;