[cfe-commits] r161636 - in /cfe/trunk: lib/StaticAnalyzer/Core/MemRegion.cpp lib/StaticAnalyzer/Core/RegionStore.cpp test/Analysis/ivars.m

Benjamin Kramer benny.kra at gmail.com
Tue Aug 21 16:01:50 PDT 2012


On 22.08.2012, at 00:53, Ted Kremenek <kremenek at apple.com> wrote:

>> -  bool AddToWorkList(const MemRegion *R, RegionCluster &C) {
>> -    if (unsigned &visited = Visited[&C])
>> -      return false;
>> -    else
>> -      visited = 1;
>> +  bool AddToWorkList(const MemRegion *R, const ClusterBindings *C) {
>> +    if (C) {
>> +      if (Visited.count(C))
>> +        return false;
>> +      Visited.insert(C);
>> +    }
>
> If Visited was still a DenseMap this lookup-and-modify would require only one lookup, and a modify of the value in place.

SmallPtrSet can do this with a single lookup, too. Insert() returns a
boolean whether the insert was successful, i.e. the entry wasn't
already in the set.

- Ben



More information about the cfe-commits mailing list