History | Log In     View a printable version of the current page.  
Issue Details (XML | Word | Printable)

Key: BOO-980
Type: Bug Bug
Status: Resolved Resolved
Resolution: Fixed
Priority: Major Major
Assignee: Marcus Griep
Reporter: Spruce Weber
Votes: 0
Watchers: 0
Operations

If you were logged in you would be able to see more operations.
Boo

performance problem in MetadataUtil.IsAttributeDefined

Created: 12/Mar/08 11:28 AM   Updated: 24/Mar/08 10:23 PM
Component/s: Compiler
Affects Version/s: 0.8.1
Fix Version/s: 0.8.2

Time Tracking:
Not Specified

File Attachments: 1. Text File MetadataUtils.cs.patch (0.7 kb)

Environment:
XP
.Net 2.0

Patch Submitted: Yes


 Description  « Hide
The method MetadataUtil.IsAttributeDefined() is indiscriminately calling System.Attribute.IsDefined() and not storing its results in any sort of cache. The patch fixes this by mapping attributeType to member to whether or not it's defined for the given member...

Dictionary<Type, Dictionary<MemberInfo, bool> >

The patch includes most of the file because none of my windows text editors will leave the line endings alone.

Below is what has been changed...

private static Dictionary<Type, Dictionary<MemberInfo, bool> > _attributeChecks = new Dictionary<Type, Dictionary<MemberInfo, bool> >();

public static bool IsAttributeDefined(MemberInfo member, Type attributeType)
{
bool isDefined;
Dictionary<MemberInfo, bool> memberInfoDict;
if (!_attributeChecks.TryGetValue(attributeType, out memberInfoDict))

{ memberInfoDict = new Dictionary<MemberInfo, bool>(); _attributeChecks.Add(attributeType, memberInfoDict); }

if (!memberInfoDict.TryGetValue(member, out isDefined))

{ isDefined = System.Attribute.IsDefined(member, attributeType); memberInfoDict.Add(member, isDefined); }

return isDefined;



 All   Comments   Work Log   Change History      Sort Order: Ascending order - Click to sort in descending order
Spruce Weber - 12/Mar/08 02:34 PM
This patch contains only portions of the file actually modified.

Marcus Griep - 24/Mar/08 10:23 PM
It is in; another quality patch, but we may be able to find additional speed-ups by optimizing/selectively caching.