Commit graph

230 commits

Author SHA1 Message Date
A Thousand Ships
889410dcda
Add String::replace_char(s) methods for performance and convenience 2025-04-10 13:08:45 +02:00
Thaddeus Crews
7a6c3b309f
Merge pull request #105130 from bruvzg/uri_fix_plus
Add uri_file_decode to handle + in file names.
2025-04-09 18:11:56 -05:00
Pāvels Nadtočajevs
b106dfd4f9
Base accessibility API. 2025-04-08 20:14:28 +03:00
Pāvels Nadtočajevs
9abe2e5294
Add uri_file_decode to handle + in file names. 2025-04-07 23:49:17 +03:00
Yufeng Ying
4f4031a675 Replace size() == 0 with is_empty(). 2025-04-02 19:18:43 +08:00
Thaddeus Crews
780cf03051
Merge pull request #104556 from Ivorforce/string-extend-instead-of-parse
Use `append_` instead of `parse_` for `String` methods.
2025-03-29 10:16:33 -05:00
bruvzg
48bfe13e4f
Add methods to decode/encode multibyte encodings. 2025-03-28 17:32:34 +02:00
Rémi Verschelde
10799d0b44
Merge pull request #104389 from Ivorforce/color-string-append
Optimize `Color::to_html` by allocating less.
2025-03-28 14:32:54 +01:00
Lukas Tenbrink
ffa6ef220b Use append_ instead of parse_ for String methods. 2025-03-27 17:51:02 +01:00
Thaddeus Crews
7fed5f29ed
Merge pull request #99826 from kiroxas/improveParseUTF8Performance
Improve `parse_utf8` performance
2025-03-24 10:00:55 -05:00
Lukas Tenbrink
143f8e933e Optimize Color::to_html by allocating less. 2025-03-20 13:42:03 +01:00
kobewi
10f6c01b9c Remove ABS in favor of Math::abs 2025-03-19 13:52:40 +01:00
Rémi Verschelde
64bd03269f
Merge pull request #104286 from Ivorforce/localvector-find
Harmonize `String`, `Vector` and `LocalVector` `find` and `rfind`.
2025-03-19 12:27:27 +01:00
rune-scape
0c7d78f455 StringLikeVariantOrder: Compare in-place 2025-03-18 11:21:30 -07:00
Lukas Tenbrink
fde71e0382 Harmonize String, Vector and LocalVector find and rfind.
Use `Span::find` for `LocalVector::find`, accepting negative `p_from`.
Return `-1` for invalid `p_from` values in `rfind`.
Accept negative values for `p_from` in `find`, starting from the back.
2025-03-18 12:37:36 +01:00
Thaddeus Crews
bb60b05ca4
Merge pull request #104182 from Ivorforce/small-little-string-function
Add missing `String + char *` function, to avoid unnecessary right side allocation to `String`.
2025-03-17 16:03:25 -05:00
Lukas Tenbrink
8c14766597 Add missing String + char * function, to avoid unnecessary right side allocation to String. 2025-03-17 17:31:35 +01:00
Lukas Tenbrink
49e860159a Move CowData find, rfind and count to Span. 2025-03-16 03:31:11 +01: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 +01: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 -05:00
Thaddeus Crews
22a7079afd
Merge pull request #104047 from YYF233333/dict_iter
Add const iteration support to `Dictionary`
2025-03-13 08:57:23 -05: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 -05: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 +08: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 -05: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 -05: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 +01:00
Julian
659d1b5d0c Fix crash caused by trailing spaces 2025-03-11 00:06:08 -04: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 -05:00
A Thousand Ships
331a43a9d8
Add String::remove_char(s) methods for performance and convenience 2025-03-10 13:19:28 +01: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 +01: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 +01: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 +01: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 -06: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 +02:00
Lukas Tenbrink
2e600789dd Optimize String ==, ends_with and begins_with by using memcmp. 2025-01-13 15:23:08 +01: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 +01: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 +01: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 -06:00
Thaddeus Crews
bf9ef5f8a5
Merge pull request #100564 from YYF233333/iwyu
Remove unused headers in core
2024-12-19 19:59:55 -06:00
Yufeng Ying
be86ce3103 Apply iwyu suggestion in core. 2024-12-19 00:43:47 +08: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 +01:00
Kiro
e4f8a7f8cf improveParseUTF8Performance 2024-12-16 09:55:11 +01: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 +01:00
Lukas Tenbrink
ef3eecd34e Optimize String.count and String.countn by avoiding repeated reallocations. 2024-12-12 00:28:13 +01: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 -06: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 +01:00
Thaddeus Crews
4b1a51d3e3
Merge pull request #100075 from demolke/simplify
Fix handling of leading `..` in simplify_path
2024-12-09 14:33:34 -06: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 -06:00
Lukas Tenbrink
875b48366c Optimize String.similarity by avoiding allocation for bigrams. 2024-12-08 13:28:40 +01:00