@@ -143,22 +143,23 @@ class estring_view : public std::string_view
143143 }
144144#if __cplusplus < 202000L
145145 bool starts_with (std::string_view x) const {
146- auto len = x.size ();
147- return length () >= len &&
148- memcmp (data (), x.data (), len) == 0 ;
146+ return size () >= x.size () && substr (0 , x.size ()) == x;
149147 }
150148
151149 bool ends_with (std::string_view x) const {
152- auto len = x.size ();
153- return length () >= len &&
154- memcmp (&*end () - len, x.data (), len) == 0 ;
150+ return size () >= x.size () && substr (size () - x.size ()) == x;
155151 }
156152#endif
157153
158- bool istarts_with (std::string_view x) const ;
159154 int icmp (std::string_view x) const ;
160155 estring tolower_fast () const ;
161156 estring toupper_fast () const ;
157+ bool istarts_with (std::string_view x) const {
158+ return size () >= x.size () && icmp (x) == 0 ;
159+ }
160+ bool iends_with (std::string_view x) const {
161+ return size () >= x.size () && substr (size () - x.size ()).icmp (x) == 0 ;
162+ }
162163
163164 template <typename Separator>
164165 struct _split
@@ -723,10 +724,6 @@ int stricmp_fast(std::string_view a, std::string_view b);
723724
724725} // namespace photon
725726
726- inline bool estring_view::istarts_with (std::string_view x) const {
727- return size () >= x.size () && photon::stricmp_fast (*this , x) == 0 ;
728- }
729-
730727inline int estring_view::icmp (std::string_view x) const {
731728 return photon::stricmp_fast (*this , x);
732729}
0 commit comments