Lukas Tenbrink
49e860159a
Move `CowData` `find`, `rfind` and `count` to `Span`.
2025-03-16 03:31:11 +07:00
Lukas Tenbrink
626ff950fb
Deduplicate `string::parse_utf32(char32_t)` in favor of just using the `Span` based function.
2025-03-13 15:11:55 +07:00
Thaddeus Crews
c1b7865ae9
Merge pull request #103557 from aaronfranke/godot-version-defines
...
Rename version defines to `GODOT_VERSION_*` to match GDExtension godot-cpp
2025-03-13 08:57:42 +07:00
Thaddeus Crews
22a7079afd
Merge pull request #104047 from YYF233333/dict_iter
...
Add const iteration support to `Dictionary`
2025-03-13 08:57:23 +07:00
Thaddeus Crews
e97bb76142
Merge pull request #100314 from Ivorforce/use-string-chr
...
Optimize `String::chr` to avoid calling `strlen`. Use `String::chr` instead of `String(&chr, 1)` where appropriate.
2025-03-13 08:57:20 +07:00
Aaron Franke
97ee05e9b7
Rename version defines to GODOT_VERSION_* to match GDExtension godot-cpp
2025-03-12 11:11:38 +07:00
Yufeng Ying
bebe037abf
Add ConstIterator to Dictionary.
2025-03-13 01:28:46 +07:00
Thaddeus Crews
19057494db
Merge pull request #100238 from Ivorforce/copy-from-unchecked-unchecked
...
Optimize String `copy_from_unchecked` to actually not check the string.
2025-03-12 10:31:54 +07:00
Thaddeus Crews
754e3b3f9a
Merge pull request #103825 from JulianHeuser/region_highlight_crash_fix
...
Fix crash related to #region/#endregion caused by trailing spaces
2025-03-11 19:54:46 +07:00
Lukas Tenbrink
541e721cac
Change String copy_from_unchecked to actually not check the string, leading to performance optimizations across substr, count, and StringBuilder.
2025-03-11 13:47:47 +07:00
Julian
659d1b5d0c
Fix crash caused by trailing spaces
2025-03-11 00:06:08 +07:00
Thaddeus Crews
8d1c1c5867
Merge pull request #92476 from AThousandShips/string_remove_char
...
Add `String::remove_char(s)` methods for performance and convenience
2025-03-10 10:01:04 +07:00
A Thousand Ships
331a43a9d8
Add `String::remove_char(s)` methods for performance and convenience
2025-03-10 13:19:28 +07:00
Lukas Tenbrink
605b62cd29
Add `Span` struct (replacing `StrRange`). Spans represent read-only access to a contiguous array, resembling `std::span`.
2025-03-09 18:19:51 +07:00
Lukas Tenbrink
b6cfcdeab5
Add `String::ascii` creator functions, to parse a char buffer as ASCII.
...
The function will log errors if any characters above value 127 are found.
2025-03-08 00:01:27 +07:00
A Thousand Ships
5113022dfe
Clean up some uses of `String::substr`
...
Cases where the end position is either equvalent to the default or past
the end of the string.
2025-03-07 14:50:38 +07:00
Thaddeus Crews
c838fe27cd
Merge pull request #99059 from MarcusPaulsson/issue_branch_2
...
Fix String::is_valid_hex_number
2025-03-06 16:36:17 +07:00
Pāvels Nadtočajevs
b50d9742c2
Fix `is_valid_float`, `Variant` parser, `Expression` parser, script highlighter, and `TextServer` not handing capital E in scientific notation.
2025-02-05 18:39:40 +07:00
Lukas Tenbrink
2e600789dd
Optimize `String` `==`, `ends_with` and `begins_with` by using `memcmp`.
2025-01-13 15:23:08 +07:00
Lukas Tenbrink
2aeca3e885
Optimize `String::chr` to avoid calling `strlen`. Use `String::chr` instead of `String(&chr, 1)` where appropriate.
2025-01-10 18:06:46 +07:00
Lukas Tenbrink
b2d881a73a
Optimize `_count` by replacing a full copy with a CoW copy for the full-string count case.
2025-01-02 18:16:06 +07:00
Thaddeus Crews
416a86f47c
Merge pull request #100434 from Ivorforce/string-copy-from-rename
...
Rename `String::copy_from` functions to their respective encodings (`parse_latin1`, `parse_wstring`, `parse_utf32`).
2024-12-19 19:59:57 +07:00
Thaddeus Crews
bf9ef5f8a5
Merge pull request #100564 from YYF233333/iwyu
...
Remove unused headers in core
2024-12-19 19:59:55 +07:00
Yufeng Ying
be86ce3103
Apply iwyu suggestion in core.
2024-12-19 00:43:47 +07:00
HP van Braam
240f510fa7
Core ubsan fixes
...
This fixes UBSAN errors reported by running our testsuite, importing the
TPS demo, and running the TPS demo. I have tried, wherever possible, to
fix issues related to reported issues but not directly reported by UBSAN
because thse code paths just happened to not have been exercised in
these cases.
These fixes apply only to errors reported, and caused by, core/
The following things have been changed:
* Make sure there are no implicit sign changing casts in core.
* Explicitly type enums that are part of a public API such that users of
the API cannot pass in wrongly-sized values leading to potential stack
corruption.
* Ensure that memcpy is never called with invalid or null pointers as
this is undefined behavior, and when the engine is built with
optimizations turned on leads to memory corruption and hard to debug
crashes.
* Replace enum values only used as static values with constexpr static
const values instead. This has no runtime overhead. This makes it so
that the size of the enums is explicit.
* Make sure that nan and inf is handled consistently in String.
* Implement a _to_int template to ensure that all of the paths use the
same algorhithm, and correct the negative integer case.
* Changed the way the json serializer precision work, and added tests to
verify the new behavior. The behavior doesn't quite match master in
particulary for negative doubles as the original code tried to cast -inf
to an int. This then led to negative doubles losing all but one of
their decimal points when serializing. Behavior in GDScript remains
unchanged.
2024-12-18 14:31:12 +07:00
Kiro
e4f8a7f8cf
improveParseUTF8Performance
2024-12-16 09:55:11 +07:00
Lukas Tenbrink
df3e9291c6
Rename `String::copy_from` functions to their respective encodings (`parse_latin1`, `parse_wstring`, `parse_utf32`).
2024-12-15 21:46:50 +07:00
Lukas Tenbrink
ef3eecd34e
Optimize `String.count` and `String.countn` by avoiding repeated reallocations.
2024-12-12 00:28:13 +07:00
Thaddeus Crews
ba66c478c0
Merge pull request #100041 from Ivorforce/optimize-string-similarity
...
Optimize String.similarity by avoiding allocation for bigrams.
2024-12-10 14:16:00 +07:00
Lukas Tenbrink
a3f48f7047
Optimize String construction from statically known strings allowing `strlen` to be evaluated at compile time, where possible.
2024-12-09 21:47:28 +07:00
Thaddeus Crews
4b1a51d3e3
Merge pull request #100075 from demolke/simplify
...
Fix handling of leading `..` in simplify_path
2024-12-09 14:33:34 +07:00
Thaddeus Crews
5b312d0e59
Merge pull request #99816 from Ivorforce/string-copy-from-optimizations
...
Optimize `String::copy_from` and `String::copy_from_unchecked` implementations, improving String allocation speed.
2024-12-09 14:33:33 +07:00
Lukas Tenbrink
875b48366c
Optimize String.similarity by avoiding allocation for bigrams.
2024-12-08 13:28:40 +07:00
Lukas Tenbrink
e1c42392c2
Improve string copy_from and copy_from_unchecked implementations, by making use of caller contracts and language spec (NULL termination and casts).
2024-12-07 01:41:25 +07:00
Lukas Tenbrink
b5c31ebb41
Add contains_char() for single-character 'contains' calls.
2024-12-06 20:23:35 +07:00
demolke
964e2b3a9e
Fix handling of leading `..` in simplify_path
...
Prior to this `..\..\texture.png` was incorrectly simplified to `texture.png`
2024-12-06 07:53:55 +07:00
Thaddeus Crews
45734bd451
Merge pull request #99817 from Ivorforce/strlen-char32_t
...
Use `strlen()` 3 times instead of custom length check implementations in ustring
2024-12-05 14:12:21 +07:00
Thaddeus Crews
06cce0e81a
Merge pull request #100016 from Ivorforce/camelcase-to-underscore-rolling-cache
...
Optimize `_camelcase_to_underscore` (and thus `String.capitalize`)
2024-12-05 14:11:59 +07:00
Lukas Tenbrink
8d82933c7c
Optimize _camelcase_to_underscore (and thus String.capitalize) by using a rolling cache of character attributes, instead of re-computing each iteration.
2024-12-04 18:39:38 +07:00
Lukas Tenbrink
0d2e13bcb8
Optimize is_valid_filename and validate_filename by caching invalid filename characters, instead of re-splitting each call.
2024-12-04 17:54:11 +07:00
Lukas Tenbrink
2b39314461
Abstract the implementation of 3 ustring string length checks with strlen, adding an implementation for char32_t.
2024-12-02 15:19:20 +07:00
Lukas Tenbrink
884cbb5333
Don't repeat calls to strlen in split, and make splitter_length const in get_slice.
2024-11-28 01:55:48 +07:00
A Thousand Ships
68f638cf02
Use `(r)find_char` instead of `(r)find` for single characters
2024-11-17 10:02:18 +07:00
Marcus Paulsson
4db07a19d0
fixed empty hex bug
...
formatting
2024-11-11 12:42:12 +07:00
Thaddeus Crews
63838c936c
Merge pull request #98278 from a-johnston/fuzzy-search-rebase
...
Add fuzzy string matching to quick open search
2024-11-10 12:12:56 +07:00
Thaddeus Crews
363c0b5fec
Merge pull request #47502 from KoBeWi/add_0
...
Always add decimal when converting float to string
2024-10-31 20:14:39 +07:00
Mansur Isaev
98c89f17c4
Add `Object` support for `String.format`
2024-10-29 22:27:33 +07:00
Adam Johnston
3ac043c508
Add fuzzy string matching to quick open search
...
Co-authored-by: sam <samsface@gmail.com>
2024-10-28 11:24:36 +07:00
kobewi
5c0f2414cd
Always add decimal when printing float
2024-10-23 15:00:21 +07:00
yeojunh
b3b24ded19
Add checks for valid base in String::num_int64, uint64().
...
- Ensure String::num_int64, uint64 returns an empty string for bases less than 2 or greater than 36.
- Added corresponding test cases to verify the behavior.
- Error messages are printed when invalid bases are encountered. These messages are suppressed in the test output.
2024-10-20 00:22:08 +07:00
Haoyu Qiu
6516ca6b11
Parse fragment from URL
2024-09-27 19:42:30 +07:00
Haoyu Qiu
a751c05b15
Fix script editor wrongly replaces and quotes non-ASCII letters
2024-09-23 00:05:16 +07:00
Haoyu Qiu
8bf4ecc026
Add `String.is_valid_unicode_identifier()`
...
- Adds `is_valid_unicode_identifier()`
- Adds `is_valid_ascii_identifier()`
- Deprecates `is_valid_identifier()`
- Renames `validate_identifier()` to `validate_ascii_identifier()`
2024-08-27 11:34:08 +07:00
Rémi Verschelde
c7702b350a
Merge pull request #92548 from AThousandShips/string_cleaning
...
[Core] Optimize some `String` methods
2024-08-26 23:28:24 +07:00
Rémi Verschelde
4afcbb1c8b
Merge pull request #92546 from AThousandShips/faster_replace
...
[Core] Optimize `String::replace` methods
2024-08-19 12:08:45 +07:00
Rémi Verschelde
49e5fbfbd2
Merge pull request #95184 from jsjtxietian/shader-include-relative
...
Fix `String::simplify_path` handling of relative paths to parent dir (`../`), fixes relative shader includes
2024-08-17 00:46:11 +07:00
Rémi Verschelde
803dfcc3cb
Merge pull request #95613 from timothyqiu/split-empty
...
Fix `split_floats` behavior when spaces are used as separators
2024-08-16 14:36:40 +07:00
Rémi Verschelde
f01e052162
Merge pull request #95549 from timothyqiu/split-translation-server
...
Split `TranslationServer` into its own file
2024-08-16 14:36:16 +07:00
Haoyu Qiu
f483c3aafa
Fix split_floats behavior when spaces are used as separators
2024-08-16 17:30:44 +07:00
Rémi Verschelde
70096c0e6a
Merge pull request #94558 from stuartcarnie/sgc/sprintf_allocations
...
Reduce allocations in `String::sprintf`
2024-08-16 10:34:28 +07:00
Rémi Verschelde
71ca5aa5ec
Merge pull request #92555 from AThousandShips/insert_improve
...
[Core] Optimize `String::insert`
2024-08-16 10:33:47 +07:00
A Thousand Ships
ee19a092d9
[Core] Optimize some `String` methods
...
Avoids unnecessary COW checks by using pointers directly.
2024-08-15 17:17:11 +07:00
A Thousand Ships
e211d08c92
[Core] Optimize `String::join`
...
Avoid reallocation by pre-computing size
2024-08-15 16:19:07 +07:00
A Thousand Ships
746c6b87eb
[Core] Optimize `String::insert`
2024-08-15 16:18:47 +07:00
A Thousand Ships
cbaec62b03
[Core] Optimize `String::replace` methods
...
Performs a single allocation, only when any instances are found, and
avoids concatenations and other unnecessary conversions.
2024-08-15 16:15:58 +07:00
Haoyu Qiu
7343dc3a5d
Split TranslationServer into its own file
2024-08-15 15:00:47 +07:00
jsjtxietian
6cf9af2817
Fix error when use relative #include in .gdshader / .gdshaderinc file
2024-08-08 11:59:14 +07:00
Stuart Carnie
67eb6bed2b
use operator += (char32_t)
...
This prevents an allocation of a new string for every character.
Additionally, use some static constants for padding and sign characters
2024-07-25 09:17:58 +07:00
A Thousand Ships
a0dbdcc3ab
Replace `find` with `contains/has` where applicable
...
* Replaces `find(...) != -1` with `contains` for `String`
* Replaces `find(...) == -1` with `!contains` for `String`
* Replaces `find(...) != -1` with `has` for containers
* Replaces `find(...) == -1` with `!has` for containers
2024-05-08 12:37:42 +07:00
Wilson E. Alvarez
d4154dbc55
Add const char * overloads to String class
...
Co-authored-by: A Thousand Ships <96648715+AThousandShips@users.noreply.github.com>
2024-05-07 10:53:00 +07:00
Haoyu Qiu
9bcda8f94c
Prefer family name in fonts' names table
2024-04-06 16:08:59 +07:00
A Thousand Ships
bb6305d1c4
[Core] Fix incorrect file sort method
2024-03-24 17:54:57 +07:00
Rémi Verschelde
8f9136963d
Merge pull request #89671 from alesliehughes/string_underrun
...
Stop possible underrun when processing a string
2024-03-24 01:21:12 +07:00
A Thousand Ships
2cbf469912
Fix sorting of files/dirs in dialogs
...
Sorts leading `_` before other characters except `.`.
2024-03-20 13:45:47 +07:00
Alistair Leslie-Hughes
87fe71f52f
Stop possible underrun when processing a string
...
Calling String::utf8("Unicode String", -1) assumes that the string will be NULL terminated.
However, the length parameter is always used to find the end of the string. So there is the
chance the character before th start of the string is read.
Making the pointer NULL in the case where it's out of range, still allows the following
to work as expected
while (ptrtmp != ptrtmp_limit && *ptrtmp)
....
2024-03-19 20:17:11 +07:00
Thaddeus Crews
9903e6779b
Enforce template syntax `typename` over `class`
2024-03-07 22:39:09 +07:00
Mika Viskari
3026b566b0
Fix String::begins_with when both strings are empty
2024-03-05 20:46:10 +07:00
Michael Alexsander
d70c45b5c8
Add option to add built-in strings in the POT generation
2024-02-28 11:34:26 +07:00
Robert Yevdokimov
13e82094ee
Remove word duplicates in comments and strings, and fix casing and punctuation
2024-02-23 17:28:28 +07:00
Danil Alexeev
c0aa88ae4f
Add Unicode support to `String.to_*_case()` methods
2024-02-22 13:58:46 +07:00
Muller-Castro
a8bc9f3e78
Add const lvalue ref to core/* container parameters
2024-02-14 11:20:36 +07:00
A Thousand Ships
15369fdb1d
Remove unnecessary `this->` expressions
2024-01-29 09:59:18 +07:00
Rémi Verschelde
5fd5176a79
Merge pull request #84462 from MewPurPur/optimize-humanizesize
...
Optimize `String.humanize_size()`
2024-01-04 14:25:40 +07:00
Rémi Verschelde
6c390b620d
Merge pull request #84445 from Rubonnek/add-const-references-clang-tidy
...
Add const references detected by clang-tidy
2024-01-04 14:25:33 +07:00
Rémi Verschelde
b66d16fcc9
Merge pull request #84375 from Rubonnek/use-const-reference
...
Add const references in `String` class
2024-01-04 14:25:27 +07:00
Micky
3b2d4ac156
Improve error message for `String.format` when using nested Arrays
2023-12-30 20:32:01 +07:00
Wilson E. Alvarez
a3cb1b096f
Add const references detected by clang-tidy
2023-12-16 13:36:44 +07:00
Pedro J. Estébanez
208c1020f5
Add 'u' format modifier for unsigned int/hex
2023-12-01 16:42:26 +07:00
bruvzg
ec052cd38a
Add unsigned char cast ifdef.
2023-11-29 11:59:18 +07:00
Yuri Sizov
edcad2ea88
Allow auto-generated node names in `PopupMenu::add_submenu_item`
2023-11-09 17:12:41 +07:00
MewPurPur
931928feb9
Optimize String.humanize_size()
2023-11-05 02:42:54 +07:00
Wilson E. Alvarez
dbc49d2a68
Add const references in String class
2023-11-02 13:49:39 +07:00
Alfonso J. Ramos
5cd7ca0ccc
Do not replace starting digit with underscore when making identifier
2023-10-04 08:05:04 +07:00
Jan Haller
43be9fa0c8
Fix platform-dependent hashing for char* and wchar_t*
...
Since char/wchar_t can be either signed or unsigned, its conversion to uint32_t leads to different values depending on platform.
In particular, the same string represented as char* (Latin-1; StringName direct construction) or uint32_t (UTF-8; constructed
via String) previously resulted in different hashes.
2023-09-24 20:57:57 +07:00
bruvzg
2b3bbde6da
[String] Fix string conversion for -0.0 float values.
2023-09-05 11:32:55 +07:00
MewPurPur
c9287e5224
Optimize String.left() and String.right()
2023-08-20 20:01:06 +07:00
Rémi Verschelde
20e24bd2bb
Merge pull request #78529 from Chaosus/string_reverse
...
Add `String.reverse` method
2023-08-16 16:53:40 +07:00
bruvzg
84a6f0d232
[String] Fix Unicode parsing error message encoding and related JSON tests.
2023-07-28 12:27:01 +07:00
MewPurPur
cc5500f7de
Fix erroneous pad_zeros warning
2023-07-08 16:16:01 +07:00
Rémi Verschelde
100082b3ac
Merge pull request #74760 from lassade/unicode-err-uses-replacement-char
...
Don't append non unicode scalar values on the string, instead use the unicode replacement char
2023-06-22 18:30:04 +07:00