[Soot-list] confused by soot.tagkit.FirstTagAggregator
Chris Pickett
chris.pickett at mail.mcgill.ca
Tue Oct 5 21:11:29 EDT 2004
Chris Pickett wrote:
> Ondrej Lhotak wrote:
>
>>On Sun, Oct 03, 2004 at 04:12:54PM -0400, Chris Pickett wrote:
>>
>>
>>>From FirstTagAggregator:
>>>
>>> public void considerTag(Tag t, Unit u)
>>> {
>>> if( units.size() > 0 && units.getLast() == u ) return;
>>> units.add(u);
>>> tags.add(t);
>>> }
>>>
>>>Doesn't this just attach the first wanted tag of each unit?
>>>
>>>I would do something like:
>>>
>>> if( tags.contains(t) ) return;
>>>
>>>instead.
>>
>>
>>Hmm, yes, this does look a lot like a bug. Your fix looks OK as well,
>>except that it's n^2 in the number of tags, which may or may not become
>>a problem.
>
>
> You could use ArrayList instead of LinkedList for tags and units.
That was a useless comment by me. You could use a HashSet as well as a
LinkedList and add tags to both, getting constant time lookup from the
HashSet and ordering from the LinkedList.
Cheers,
Chris
> The only subclass of FirstTagAggregator is LineNumberTagAggregator, and
> it looks to be positively affected by this change.
>
> Chris
> _______________________________________________
> Soot-list mailing list
> Soot-list at sable.mcgill.ca
> http://www.sable.mcgill.ca/mailman/listinfo/soot-list
>
More information about the Soot-list
mailing list