Merge pull request #104127 from Ivorforce/360-noclip

Remove `String` clipping constructors.
This commit is contained in:
Rémi Verschelde 2025-03-19 12:27:10 +01:00
commit 2fa721b1bc
No known key found for this signature in database
GPG key ID: C3336907360768E1
12 changed files with 24 additions and 41 deletions

View file

@ -366,7 +366,7 @@ GDScriptTokenizer::Token GDScriptTokenizerText::make_token(Token::Type p_type) {
token.end_column = column;
token.leftmost_column = leftmost_column;
token.rightmost_column = rightmost_column;
token.source = String(_start, _current - _start);
token.source = String::utf32(Span(_start, _current - _start));
if (p_type != Token::ERROR && cursor_line > -1) {
// Also count whitespace after token.
@ -588,7 +588,7 @@ GDScriptTokenizer::Token GDScriptTokenizerText::potential_identifier() {
return token;
}
String name(_start, len);
String name = String::utf32(Span(_start, len));
if (len < MIN_KEYWORD_LENGTH || len > MAX_KEYWORD_LENGTH) {
// Cannot be a keyword, as the length doesn't match any.
return make_identifier(name);
@ -863,7 +863,7 @@ GDScriptTokenizer::Token GDScriptTokenizerText::number() {
// Create a string with the whole number.
int len = _current - _start;
String number = String(_start, len).remove_char('_');
String number = String::utf32(Span(_start, len)).remove_char('_');
// Convert to the appropriate literal type.
if (base == 16) {

View file

@ -182,7 +182,7 @@ Error GDScriptTokenizerBuffer::set_code_buffer(const Vector<uint8_t> &p_buffer)
cs.write[j] = decode_uint32(tmp);
}
String s(reinterpret_cast<const char32_t *>(cs.ptr()), len);
String s = String::utf32(Span(reinterpret_cast<const char32_t *>(cs.ptr()), len));
b += len * 4;
total_len -= len * 4;
identifiers.write[i] = s;

View file

@ -212,7 +212,8 @@ String X509CertificateMbedTLS::save_to_string() {
int ret = mbedtls_pem_write_buffer(PEM_BEGIN_CRT, PEM_END_CRT, cert.raw.p, cert.raw.len, w, sizeof(w), &wrote);
ERR_FAIL_COND_V_MSG(ret != 0 || wrote == 0, String(), "Error saving the certificate.");
buffer += String((char *)w, wrote);
// PEM is base64, aka ascii
buffer += String::ascii(Span((char *)w, wrote));
crt = crt->next;
}
if (buffer.length() <= PEM_MIN_SIZE) {

View file

@ -326,7 +326,7 @@ int RegEx::_sub(const String &p_subject, const String &p_replacement, int p_offs
pcre2_match_context_free_32(mctx);
if (res >= 0) {
r_output = String(output.ptr(), olength) + p_subject.substr(length);
r_output = String::utf32(Span(output.ptr(), olength)) + p_subject.substr(length);
}
return res;

View file

@ -151,7 +151,7 @@ Error WSLPeer::accept_stream(Ref<StreamPeer> p_stream) {
}
bool WSLPeer::_parse_client_request() {
Vector<String> psa = String((const char *)handshake_buffer->get_data_array().ptr(), handshake_buffer->get_position() - 4).split("\r\n");
Vector<String> psa = String::ascii(Span((const char *)handshake_buffer->get_data_array().ptr(), handshake_buffer->get_position() - 4)).split("\r\n");
int len = psa.size();
ERR_FAIL_COND_V_MSG(len < 4, false, "Not enough response headers, got: " + itos(len) + ", expected >= 4.");
@ -416,7 +416,7 @@ void WSLPeer::_do_client_handshake() {
}
bool WSLPeer::_verify_server_response() {
Vector<String> psa = String((const char *)handshake_buffer->get_data_array().ptr(), handshake_buffer->get_position() - 4).split("\r\n");
Vector<String> psa = String::ascii(Span((const char *)handshake_buffer->get_data_array().ptr(), handshake_buffer->get_position() - 4)).split("\r\n");
int len = psa.size();
ERR_FAIL_COND_V_MSG(len < 4, false, "Not enough response headers. Got: " + itos(len) + ", expected >= 4.");