Document rationale for Dart VM flag prefix match (flutter/engine#30195)
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.
This commit is contained in:
@@ -168,7 +168,10 @@ static std::vector<std::string> 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() &&
|
||||
|
||||
Reference in New Issue
Block a user