[cfe-commits] r139789 - /cfe/trunk/lib/Basic/Targets.cpp

Jonathan Sauer jonathan.sauer at gmx.de
Fri Sep 23 08:22:21 PDT 2011


Hello,

> I would however suggest a sorted   std::vector<llvm::StringRef>  for AvailableFeatures. It provides a lesser memory footprint (about 16 bytes per entry) and offers basically the same complexity for the interface here:   std::lower_bound(AvailableFeatures.begin(), AvailableFeatures.end(), Name) != AvailableFeatures.end();

Is that check enough? <http://www.sgi.com/tech/stl/lower_bound.html> says:

| The first version of lower_bound returns the furthermost iterator i in [first, last) such that,
| for every iterator j in [first, i), *j < value.

This can also be true if *i > value. So, I think the check should be:

   iterator it = std::lower_bound(AvailableFeatures.begin(), AvailableFeatures.end(), Name);
   if (it != AvailableFeatures.end() && *it == Name) ...

Please correct me if I'm wrong.

Of course, since r140320 uses std::binary_search instead of std::lower_bound, the point is somewhat moot ;-)


Jonathan





More information about the cfe-commits mailing list