@@ -177,7 +177,11 @@ class [[nodiscard]] CharStringT {
177177public:
178178 _FORCE_INLINE_ T *ptrw () { return _cowdata.ptrw (); }
179179 _FORCE_INLINE_ const T *ptr () const { return _cowdata.ptr (); }
180+ _FORCE_INLINE_ const T *get_data () const { return ptr () ? ptr () : &_null; }
181+
180182 _FORCE_INLINE_ int size () const { return _cowdata.size (); }
183+ _FORCE_INLINE_ int length () const { return ptr () ? size () - 1 : 0 ; }
184+ _FORCE_INLINE_ bool is_empty () const { return length () == 0 ; }
181185
182186 _FORCE_INLINE_ operator Span<T>() const { return Span (ptr (), length ()); }
183187 _FORCE_INLINE_ Span<T> span () const { return Span (ptr (), length ()); }
@@ -226,14 +230,6 @@ class [[nodiscard]] CharStringT {
226230 return *this ;
227231 }
228232
229- _FORCE_INLINE_ int length () const { return size () ? size () - 1 : 0 ; }
230- _FORCE_INLINE_ const T *get_data () const {
231- if (size ()) {
232- return &operator [](0 );
233- }
234- return &_null;
235- }
236-
237233protected:
238234 void copy_from (const T *p_cstr) {
239235 if (!p_cstr) {
@@ -313,7 +309,11 @@ class [[nodiscard]] String {
313309
314310 _FORCE_INLINE_ char32_t *ptrw () { return _cowdata.ptrw (); }
315311 _FORCE_INLINE_ const char32_t *ptr () const { return _cowdata.ptr (); }
312+ _FORCE_INLINE_ const char32_t *get_data () const { return ptr () ? ptr () : &_null; }
313+
316314 _FORCE_INLINE_ int size () const { return _cowdata.size (); }
315+ _FORCE_INLINE_ int length () const { return ptr () ? size () - 1 : 0 ; }
316+ _FORCE_INLINE_ bool is_empty () const { return length () == 0 ; }
317317
318318 _FORCE_INLINE_ operator Span<char32_t >() const { return Span (ptr (), length ()); }
319319 _FORCE_INLINE_ Span<char32_t > span () const { return Span (ptr (), length ()); }
@@ -377,14 +377,6 @@ class [[nodiscard]] String {
377377 signed char filecasecmp_to (const String &p_str) const ;
378378 signed char filenocasecmp_to (const String &p_str) const ;
379379
380- const char32_t *get_data () const ;
381- /* standard size stuff */
382-
383- _FORCE_INLINE_ int length () const {
384- int s = size ();
385- return s ? (s - 1 ) : 0 ; // length does not include zero
386- }
387-
388380 bool is_valid_string () const ;
389381
390382 /* debug, error messages */
@@ -587,7 +579,6 @@ class [[nodiscard]] String {
587579 Vector<uint8_t > sha1_buffer () const ;
588580 Vector<uint8_t > sha256_buffer () const ;
589581
590- _FORCE_INLINE_ bool is_empty () const { return length () == 0 ; }
591582 _FORCE_INLINE_ bool contains (const char *p_str) const { return find (p_str) != -1 ; }
592583 _FORCE_INLINE_ bool contains (const String &p_str) const { return find (p_str) != -1 ; }
593584 _FORCE_INLINE_ bool contains_char (char32_t p_chr) const { return find_char (p_chr) != -1 ; }
0 commit comments