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

Improve internal string allocation methods #398

Merged
merged 3 commits into from
May 10, 2024

Conversation

chqrlie
Copy link
Collaborator

@chqrlie chqrlie commented May 7, 2024

String values are allocated as temporary or final results. This commit attempts to improve the consistency and performance of this step.

  • define JS_NewString as an inline function to allow simple expansion of strlen() for string literals
  • document string contents constraints regarding UTF-8 encoding.
  • rename js_new_string8 as js_new_string8_len. takes const char *.
  • new inline function js_new_string8 takes const char *, computes string length with strlen and calls js_new_string8_len. No overhead for string literals
  • use internal string allocation functions where appropriate, remove overhead

String values are allocated as temporary or final results. This commit
attempts to improve the consistency and performance of this step.

- define `JS_NewString` as an inline function to allow simple expansion
  of `strlen()` for string literals
- document string contents constraints regarding UTF-8 encoding.
- rename `js_new_string8` as `js_new_string8_len`. takes `const char *`.
- new inline function `js_new_string8` takes `const char *`, computes
  string length with `strlen` and calls `js_new_string8_len`. No overhead
  for string literals
- use internal string allocation functions where appropriate, remove overhead
quickjs.c Show resolved Hide resolved
quickjs.c Show resolved Hide resolved
quickjs.c Show resolved Hide resolved
quickjs.c Show resolved Hide resolved
quickjs.c Show resolved Hide resolved
quickjs.c Show resolved Hide resolved
Copy link
Contributor

@saghul saghul left a comment

Choose a reason for hiding this comment

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

All goood! 🚀

@chqrlie chqrlie merged commit b81d4de into quickjs-ng:master May 10, 2024
47 checks passed
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