1
0
mirror of https://github.com/godotengine/godot.git synced 2025-11-04 12:00:25 +00:00

Remove String clipping constructors.

Callers should instead call constructors with explicit encoding names, with known length `Span`.
This commit is contained in:
Lukas Tenbrink
2025-03-14 16:54:44 +01:00
parent b377562b52
commit a23f630781
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) {