Skip to content

Conversation

Sec-ant
Copy link
Contributor

@Sec-ant Sec-ant commented Jul 14, 2023

Safely return bytes as Uint8Array in ReadResult via emscripten::val::global

should fix the issue mentioned in #584 and 8a0c458

@Sec-ant Sec-ant changed the title wasm: bytes in ReadResult. wasm: bytes in ReadResult Jul 14, 2023
Sec-ant added 2 commits July 14, 2023 11:54
safely return bytes as `Uint8Array` in `ReadResult` via `emscripten::val::global`
@Sec-ant Sec-ant changed the title wasm: bytes in ReadResult WASM: bytes in ReadResult Jul 14, 2023
for (auto&& result : results) {
readResults.push_back({ToString(result.format()), result.text(), std::string(result.bytes().asString()),
ToString(result.error()), result.position(), result.symbologyIdentifier()});
ByteArray bytes = result.bytes();
Copy link
Collaborator

Choose a reason for hiding this comment

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

Very nice! I have one tiny improvement to suggest: this line makes a copy of result.bytes(), which is unnecessary. Either use result.bytes().data() below or change this line to const ByteArray& bytes = result.bytes(). I have not tested your changes myself, will do.

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Thanks, fixed now.

@axxel axxel merged commit f3387c3 into zxing-cpp:master Jul 14, 2023
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