From ba63fa731ec46f776a9bbfd06b94c4c31e8e0e90 Mon Sep 17 00:00:00 2001 From: Chris Kennelly Date: Thu, 15 Dec 2016 13:25:26 -0800 Subject: [PATCH] Remove spurious NULL checks in ArenaStringPtr::CreateInstance. --- src/google/protobuf/arenastring.h | 15 ++++----------- 1 file changed, 4 insertions(+), 11 deletions(-) diff --git a/src/google/protobuf/arenastring.h b/src/google/protobuf/arenastring.h index b60ee3790..726c19d49 100755 --- a/src/google/protobuf/arenastring.h +++ b/src/google/protobuf/arenastring.h @@ -283,22 +283,15 @@ struct LIBPROTOBUF_EXPORT ArenaStringPtr { GOOGLE_ATTRIBUTE_NOINLINE void CreateInstance(::google::protobuf::Arena* arena, const ::std::string* initial_value) { - // Assumes ptr_ is not NULL. - if (initial_value != NULL) { - ptr_ = new ::std::string(*initial_value); - } else { - ptr_ = new ::std::string(); - } + GOOGLE_DCHECK(initial_value != NULL); + ptr_ = new ::std::string(*initial_value); if (arena != NULL) { arena->Own(ptr_); } } GOOGLE_ATTRIBUTE_NOINLINE void CreateInstanceNoArena(const ::std::string* initial_value) { - if (initial_value != NULL) { - ptr_ = new ::std::string(*initial_value); - } else { - ptr_ = new ::std::string(); - } + GOOGLE_DCHECK(initial_value != NULL); + ptr_ = new ::std::string(*initial_value); } };