[PATCH] D39694: [VerifyDiagnosticConsumer] support -verify=<prefixes>

Hal Finkel via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Thu Dec 14 14:41:26 PST 2017

hfinkel added inline comments.

Comment at: lib/Frontend/VerifyDiagnosticConsumer.cpp:398
+    // DToken is foo-bar-warning, but foo is the only -verify prefix).
+    if (Prefixes.end() == std::find(Prefixes.begin(), Prefixes.end(), DToken))
+      continue;
> Converts from std::vector to std::set for more efficient prefix lookup.

Don't do that. First, std::find is O(N) here anyway. You'd want to use Prefixes.find(...) instead. However, this set is essentially constant and you're trying to optimize the lookup. In such a case, std::set is not a good choice. Just use a sorted vector instead (e.g., call std::sort on the vector), and then use std::binary_search here. That's likely much faster.


More information about the cfe-commits mailing list