Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Ensure parse_utf8 has length of string passed in when available #99834

Merged
merged 1 commit into from
Dec 3, 2024

Conversation

kiroxas
Copy link
Contributor

@kiroxas kiroxas commented Nov 29, 2024

As seen in #99826, parse utf_8 is faster when it doesn't have to find the size of the string first.
So if calling code has it, make sure to pass it along.

@kiroxas kiroxas requested review from a team as code owners November 29, 2024 13:40
Copy link
Contributor

@Ivorforce Ivorforce left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It might be that this is changing behavior; current code is terminating on NULL even if the actual string length was larger. Not that i'm again it; just noting. The tests will probably see if it still works.

platform/windows/windows_utils.cpp Outdated Show resolved Hide resolved
@kiroxas
Copy link
Contributor Author

kiroxas commented Nov 29, 2024

It might be that this is changing behavior; current code is terminating on NULL even if the actual string length was larger. Not that i'm again it; just noting. The tests will probably see if it still works.

It should not, as length is just a hint to be able to allocate a destination buffer large enough to hold the result ( which is 1 to 1 if the file is just ASCII, or could be 4 to 1 if only 4 bytes codepoints). It is only used in the conversion algorithm as a stop condition, and if we iterated past the length, it was a bug, as the case I changed allocated length bytes just before the call. If it stopped on null, we will stop on null too, even if it's smaller than length. The loop condition is the same in current implementation and the PR.

@Chaosus Chaosus added this to the 4.4 milestone Nov 30, 2024
@AThousandShips AThousandShips modified the milestones: 4.4, 4.x Nov 30, 2024
@akien-mga akien-mga modified the milestones: 4.x, 4.4 Dec 3, 2024
@Repiteo Repiteo merged commit 1719f8e into godotengine:master Dec 3, 2024
20 checks passed
@Repiteo
Copy link
Contributor

Repiteo commented Dec 3, 2024

Thanks!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

Successfully merging this pull request may close these issues.

7 participants