emscripten-core / emscripten-core/emscripten

embind should use the length that std::string already knows

Open
#13,500 4 comments 0 reactions 0 assignees View on GitHub
Dominant language
C++
Stars
27.6k
Forks
3.6k
Avg merge
1d 1h
Merged PRs (30d)
105

Description

Per [a comment on another issue](https://github.com/emscripten-core/emscripten/pull/13304#issuecomment-778637859) embind doesn't make use of `std::string` knowing its length when converting to a JS string. Treating `std::string` as a C string is both unnecessarily inefficient and, in the case of embedded U+0000, in correct.

Please use the length already known and avoid `strlen` when converting a `std::string` to a JS string.

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.