Explorar o código

Don't copy strings in Startswith, Endswith

Adrian Wielgosik %!s(int64=10) %!d(string=hai) anos
pai
achega
c1f961ecbb
Modificáronse 1 ficheiros con 2 adicións e 2 borrados
  1. 2 2
      apt-pkg/contrib/strutl.cc

+ 2 - 2
apt-pkg/contrib/strutl.cc

@@ -71,14 +71,14 @@ bool Endswith(const std::string &s, const std::string &end)
 {
 {
    if (end.size() > s.size())
    if (end.size() > s.size())
       return false;
       return false;
-   return (s.substr(s.size() - end.size(), s.size()) == end);
+   return (s.compare(s.size() - end.size(), end.size(), end) == 0);
 }
 }
 
 
 bool Startswith(const std::string &s, const std::string &start)
 bool Startswith(const std::string &s, const std::string &start)
 {
 {
    if (start.size() > s.size())
    if (start.size() > s.size())
       return false;
       return false;
-   return (s.substr(0, start.size()) == start);
+   return (s.compare(0, start.size(), start) == 0);
 }
 }
 
 
 }
 }