diff --git a/src/cpp/ext/proto_server_reflection.cc b/src/cpp/ext/proto_server_reflection.cc index 7d008794c43..95a30d892a9 100644 --- a/src/cpp/ext/proto_server_reflection.cc +++ b/src/cpp/ext/proto_server_reflection.cc @@ -176,10 +176,10 @@ template void ProtoServerReflectionBackend::FillFileDescriptorResponse( const protobuf::FileDescriptor* file_desc, Response* response, std::unordered_set* seen_files) const { - if (seen_files->find(file_desc->name()) != seen_files->end()) { + bool inserted = seen_files->emplace(file_desc->name()).second; + if (!inserted) { return; } - seen_files->insert(file_desc->name()); protobuf::FileDescriptorProto file_desc_proto; std::string data;