mirror of
https://github.com/protobuf-c/protobuf-c.git
synced 2024-12-26 12:41:01 +08:00
Fix codesmell "or with 0" in generated flags
Signed-off-by: Daniel Egger <daniel@eggers-club.de> [edmonds: From https://github.com/protobuf-c/protobuf-c/pull/523.] [edmonds: Adjust find string from "0 |" to "0 | ", test against `== 0` rather than `!= std::string::npos` so that the find/erase calls are anchored to the same portion of the string.]
This commit is contained in:
parent
5312647592
commit
d465ae9d44
@ -159,6 +159,11 @@ void FieldGenerator::GenerateDescriptorInitializerGeneric(io::Printer* printer,
|
||||
if (oneof != NULL)
|
||||
variables["flags"] += " | PROTOBUF_C_FIELD_FLAG_ONEOF";
|
||||
|
||||
// Eliminate codesmell "or with 0"
|
||||
if (variables["flags"].find("0 | ") == 0) {
|
||||
variables["flags"].erase(0, 4);
|
||||
}
|
||||
|
||||
printer->Print("{\n");
|
||||
if (descriptor_->file()->options().has_optimize_for() &&
|
||||
descriptor_->file()->options().optimize_for() ==
|
||||
|
Loading…
x
Reference in New Issue
Block a user