- Use "B" insted of "Bytes" to be more compact
- Use suffixes that denote a binary prefix
- Make suffixes localizable
This removes the need for the custom
`EditorNetworkProfiler:_format_bandwidth()` method.
Godot core needs MD5/SHA256/AES/Base64 which used to be provided by
separate libraries.
Since we bundle mbedtls in most cases, and we can easily only include
the needed sources if we so desire, let's use it.
To simplify library changes in the future, and better isolate header
dependencies all functions have been wrapped around inside a class in
`core/math/crypto_base.h`.
If the mbedtls module is disabled, we only bundle the needed source
files independently of the `builtin_mbedtls` option.
If the module is enabled, the `builtin_mbedtls` option works as usual.
Also remove some unused headers from StreamPeerMbedTLS which were
causing build issues.
Unlike the old custom method, the `String::humanize_size()`
method works well with file sizes above 2 GB.
This also tweaks the suffixes for spacing consistency and
uses the correct acronym for exabytes (EB).
This closes#29610.
Added constructor and assignment operator for CharString
from const char* to simplify memory management when working with
utf8/ascii strings for APIs taking char*.
Reworked OS_X11::set_context to use CharString and avoid some manual
memory management.
Background: lstrip and rstrip were broken by changes to String in:
0e29f7974b
which removed it's access to Vector::find(CharType).
Moved Vector's find up into CowData so it can be shared by Vector and String.
Added String::find_char using CowData::find.
Implemented rstrip and lstrip using find_char.
Added a few tests for String rstrip and lstrip.
As per the C++ standard 21.3.4.1 for std::string:
Returns: If pos < size(), returns data()[pos]. Otherwise, if pos ==
size(), the const version returns charT(). Otherwise, the behavior is
undefined.
Since the behavior is undefined Godot now does the same thing for const
and non-const versions of operator[].
This fixes#21242 and fixes#22221.
By introducing an intermediate proxy class for the array subscript
operator for String and CharString we can control better when CowData
will actually CoW.
This should improve performance of String usage for most cases.
Previosly String::format used variant.get_construct_string() to convert
the passed Variants to Strings. This however did not match the expected
printing behavior of some datatypes: Strings for example turned out
escaped.
This fix replaces the call to get_construct_string() with a simple
conversion. This makes String::format consistent with "%s" % "sth" and
formated Variants turn out like printed as expected.