From 1ea8c9420a3d60b3559f9a47be8bd453856ae7ee Mon Sep 17 00:00:00 2001 From: Chris Bracken Date: Tue, 7 Dec 2021 13:33:10 -0800 Subject: [PATCH] Document rationale for Dart VM flag prefix match Dart VM flags are passed to Flutter via an fml::CommandLine::Option that looks something like: {"dart-flags, "--max_profile_depth 1,--trace_service"} We perform a prefix match to handle cases where Dart VM options take arguments. Adding the comment since in a recent review I found myself wondering why we're using a prefix match to begin with. While the original author had forgotten, the good news is, he wrote a test that covers this exact case. This comment just removes one level of indirection for future readers. --- shell/common/switches.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/shell/common/switches.cc b/shell/common/switches.cc index 8b831b650e672..491ca931979d8 100644 --- a/shell/common/switches.cc +++ b/shell/common/switches.cc @@ -168,7 +168,10 @@ static std::vector ParseCommaDelimited(const std::string& input) { static bool IsAllowedDartVMFlag(const std::string& flag) { for (uint32_t i = 0; i < fml::size(gAllowedDartFlags); ++i) { const std::string& allowed = gAllowedDartFlags[i]; - // Check that the prefix of the flag matches one of the allowed flags. + // Check that the prefix of the flag matches one of the allowed flags. This + // is to handle cases where flags take arguments, such as in + // "--max_profile_depth 1". + // // We don't need to worry about cases like "--safe --sneaky_dangerous" as // the VM will discard these as a single unrecognized flag. if (flag.length() >= allowed.length() &&