Skip to content

Commit 8aaecd5

Browse files
ttsugriyfacebook-github-bot
authored andcommitted
Short circuit blacklist check.
Summary: `count` *always* compares both strings even if the first one is already a match. It's possible to use `std::ranges::find` instead of count but it's more verbose and unnecessary for such a simple case Reviewed By: dmm-fb Differential Revision: D75712432 fbshipit-source-id: 9eae3d9de9ae1c1f4ea8b27b26a22412fb9cfa6a
1 parent 379eaed commit 8aaecd5

File tree

1 file changed

+1
-5
lines changed

1 file changed

+1
-5
lines changed

fb303/ServiceData.cpp

Lines changed: 1 addition & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -643,11 +643,7 @@ ServiceData::SetOptionResult ServiceData::setOptionWithResult(
643643

644644
// By default allow modifying glog verbosity (options 'v' or 'vmodule')
645645
auto useOptionsAsFlags = useOptionsAsFlags_.load(std::memory_order_relaxed);
646-
static constexpr StringPiece blacklistedOptions[] = {
647-
StringPiece{"logmailer"}, StringPiece{"whitelist_flags"}};
648-
if (std::count(
649-
std::begin(blacklistedOptions), std::end(blacklistedOptions), key) >
650-
0) {
646+
if (key == "logmailer" || key == "whitelist_flags") {
651647
return SetOptionResult::CmdlineBlacklisted;
652648
}
653649

0 commit comments

Comments
 (0)