Jelajahi Sumber

Deduplicate string suffix predicates

Yuriy Chernyshov 4 tahun lalu
induk
melakukan
87f1d9e2f6
1 mengubah file dengan 1 tambahan dan 5 penghapusan
  1. 1 5
      src/google/protobuf/compiler/python/python_generator.cc

+ 1 - 5
src/google/protobuf/compiler/python/python_generator.cc

@@ -69,16 +69,12 @@ namespace python {
 
 
 namespace {
 namespace {
 
 
-bool StrEndsWith(StringPiece sp, StringPiece x) {
-  return sp.size() >= x.size() && sp.substr(sp.size() - x.size()) == x;
-}
-
 // Returns a copy of |filename| with any trailing ".protodevel" or ".proto
 // Returns a copy of |filename| with any trailing ".protodevel" or ".proto
 // suffix stripped.
 // suffix stripped.
 // TODO(robinson): Unify with copy in compiler/cpp/internal/helpers.cc.
 // TODO(robinson): Unify with copy in compiler/cpp/internal/helpers.cc.
 std::string StripProto(const std::string& filename) {
 std::string StripProto(const std::string& filename) {
   const char* suffix =
   const char* suffix =
-      StrEndsWith(filename, ".protodevel") ? ".protodevel" : ".proto";
+      HasSuffixString(filename, ".protodevel") ? ".protodevel" : ".proto";
   return StripSuffixString(filename, suffix);
   return StripSuffixString(filename, suffix);
 }
 }