+2003-10-09 Gonzalo Paniagua Javier <gonzalo@ximian.com>
+
+ * MonoCustomAttrs.cs: from_cache is now thread-safe. Yeah, I got a
+ duplicate entry exception.
+
2003-10-08 Ben Maurer <bmaurer@users.sourceforge.net>
* DateTime.cs (ToString): Total rewrite, fixes #49358.
private static object[] from_cache (ICustomAttributeProvider obj)
{
- object[] res = (object []) handle_to_attrs [obj];
- if (res != null)
+ lock (handle_to_attrs) {
+ object[] res = (object []) handle_to_attrs [obj];
+ if (res != null)
+ return res;
+ res = GetCustomAttributes (obj);
+ handle_to_attrs.Add (obj, res);
return res;
- res = GetCustomAttributes (obj);
- handle_to_attrs.Add (obj, res);
- return res;
+ }
}
internal static Attribute GetCustomAttribute (ICustomAttributeProvider obj,
return r;
}
- ArrayList a = new ArrayList ();
+ ArrayList a = new ArrayList (res.Length < 16 ? res.Length : 16);
ICustomAttributeProvider btype = obj;
do {
foreach (object attr in res)