Skip to content

Commit b04736f

Browse files
committed
Fixed warnings in idl_gen_go.cpp
1 parent bc240b3 commit b04736f

File tree

1 file changed

+7
-8
lines changed

1 file changed

+7
-8
lines changed

src/idl_gen_go.cpp

Lines changed: 7 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -161,7 +161,7 @@ class GoGenerator : public BaseGenerator {
161161

162162
// A single enum member.
163163
void EnumMember(const EnumDef &enum_def, const EnumVal &ev,
164-
const int max_name_length, std::string *code_ptr) {
164+
size_t max_name_length, std::string *code_ptr) {
165165
std::string &code = *code_ptr;
166166
code += "\t";
167167
code += enum_def.name;
@@ -189,7 +189,7 @@ class GoGenerator : public BaseGenerator {
189189

190190
// A single enum name member.
191191
void EnumNameMember(const EnumDef &enum_def, const EnumVal ev,
192-
const int max_name_length, std::string *code_ptr) {
192+
size_t max_name_length, std::string *code_ptr) {
193193
std::string &code = *code_ptr;
194194
code += "\t";
195195
code += enum_def.name;
@@ -229,7 +229,7 @@ class GoGenerator : public BaseGenerator {
229229

230230
// A single enum value member.
231231
void EnumValueMember(const EnumDef &enum_def, const EnumVal ev,
232-
const int max_name_length, std::string *code_ptr) {
232+
size_t max_name_length, std::string *code_ptr) {
233233
std::string &code = *code_ptr;
234234
code += "\t\"";
235235
code += ev.name;
@@ -775,7 +775,7 @@ class GoGenerator : public BaseGenerator {
775775
void GenEnum(const EnumDef &enum_def, std::string *code_ptr) {
776776
if (enum_def.generated) return;
777777

778-
const int max_name_length = MaxNameLength(enum_def);
778+
auto max_name_length = MaxNameLength(enum_def);
779779
cur_name_space_ = enum_def.defined_namespace;
780780

781781
GenComment(enum_def.doc_comment, code_ptr, nullptr);
@@ -989,12 +989,11 @@ class GoGenerator : public BaseGenerator {
989989

990990
const Namespace *CurrentNameSpace() const { return cur_name_space_; }
991991

992-
static int MaxNameLength(const EnumDef &enum_def) {
993-
int max = 0;
992+
static size_t MaxNameLength(const EnumDef &enum_def) {
993+
size_t max = 0;
994994
for (auto it = enum_def.Vals().begin(); it != enum_def.Vals().end();
995995
++it) {
996-
const int length = (*it)->name.length();
997-
max = length > max ? length : max;
996+
max = std::max((*it)->name.length(), max);
998997
}
999998
return max;
1000999
}

0 commit comments

Comments
 (0)