mirror of
https://github.com/godotengine/godot.git
synced 2025-10-19 16:03:29 +00:00
Merge pull request #110932 from Ivorforce/string-buffer-size-comment
Add comments to `String::size` to lead people to `length()` and explain the difference.
This commit is contained in:
commit
d8df20a2e6
1 changed files with 6 additions and 0 deletions
|
@ -180,7 +180,10 @@ public:
|
||||||
_FORCE_INLINE_ const T *ptr() const { return _cowdata.ptr(); }
|
_FORCE_INLINE_ const T *ptr() const { return _cowdata.ptr(); }
|
||||||
_FORCE_INLINE_ const T *get_data() const { return size() ? ptr() : &_null; }
|
_FORCE_INLINE_ const T *get_data() const { return size() ? ptr() : &_null; }
|
||||||
|
|
||||||
|
// Returns the number of characters in the buffer, including the terminating NUL character.
|
||||||
|
// In most cases, length() should be used instead.
|
||||||
_FORCE_INLINE_ int size() const { return _cowdata.size(); }
|
_FORCE_INLINE_ int size() const { return _cowdata.size(); }
|
||||||
|
// Returns the number of characters in the string (excluding terminating NUL character).
|
||||||
_FORCE_INLINE_ int length() const { return size() ? size() - 1 : 0; }
|
_FORCE_INLINE_ int length() const { return size() ? size() - 1 : 0; }
|
||||||
_FORCE_INLINE_ bool is_empty() const { return length() == 0; }
|
_FORCE_INLINE_ bool is_empty() const { return length() == 0; }
|
||||||
|
|
||||||
|
@ -302,7 +305,10 @@ public:
|
||||||
_FORCE_INLINE_ const char32_t *ptr() const { return _cowdata.ptr(); }
|
_FORCE_INLINE_ const char32_t *ptr() const { return _cowdata.ptr(); }
|
||||||
_FORCE_INLINE_ const char32_t *get_data() const { return size() ? ptr() : &_null; }
|
_FORCE_INLINE_ const char32_t *get_data() const { return size() ? ptr() : &_null; }
|
||||||
|
|
||||||
|
// Returns the number of characters in the buffer, including the terminating NUL character.
|
||||||
|
// In most cases, length() should be used instead.
|
||||||
_FORCE_INLINE_ int size() const { return _cowdata.size(); }
|
_FORCE_INLINE_ int size() const { return _cowdata.size(); }
|
||||||
|
// Returns the number of characters in the string (excluding terminating NUL character).
|
||||||
_FORCE_INLINE_ int length() const { return size() ? size() - 1 : 0; }
|
_FORCE_INLINE_ int length() const { return size() ? size() - 1 : 0; }
|
||||||
_FORCE_INLINE_ bool is_empty() const { return length() == 0; }
|
_FORCE_INLINE_ bool is_empty() const { return length() == 0; }
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue