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

[embind] Simplify string.toWireType. NFC #23369

Open
wants to merge 1 commit into
base: main
Choose a base branch
from

Conversation

sbc100
Copy link
Collaborator

@sbc100 sbc100 commented Jan 10, 2025

  • Simplify the type check
  • Restructure the loop to avoid checking stdStringIsUTF8 twice

@sbc100 sbc100 requested a review from brendandahl January 10, 2025 20:42
@sbc100 sbc100 force-pushed the string_toWireType branch 3 times, most recently from 466eb50 to 96ed3ac Compare January 10, 2025 20:54
@sbc100 sbc100 changed the title [embind] Simplify string.toWireType type check. NFC [embind] Simplify string.toWireType. NFC Jan 10, 2025
src/embind/embind.js Outdated Show resolved Hide resolved
@sbc100 sbc100 force-pushed the string_toWireType branch from 96ed3ac to bf74d1c Compare January 10, 2025 22:29
@sbc100 sbc100 requested a review from brendandahl January 10, 2025 22:30
@sbc100 sbc100 force-pushed the string_toWireType branch from bf74d1c to 6d496c4 Compare January 10, 2025 22:41
- Simplify the type check
- Remove the final argument from sringToUTF8
- Restructure the loop to avoid checking stdStringIsUTF8 twice
@sbc100 sbc100 force-pushed the string_toWireType branch from 6d496c4 to ad13882 Compare January 10, 2025 23:03
if (valueIsOfTypeString) {
if (valueIsOfTypeString) {
if (stdStringIsUTF8) {
stringToUTF8(value, ptr, length);
Copy link
Collaborator

Choose a reason for hiding this comment

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

Looks like tests are still failing, + 1 is needed or something else going on?

Copy link
Collaborator Author

Choose a reason for hiding this comment

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

Yup, you are correct.

Strange.. his code doesn't actually require null termination (it uses lenght-pefix instead)... but stringToUTF8 unconditionally does.

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

Successfully merging this pull request may close these issues.

2 participants