Skip to content

Conversation

@rupertlssmith
Copy link

Fixes an issue where appending string char by char with += leads to a lot of 'concatenated string' elements on the heap, and consumes a lot more memory than a simple string needs. Using array.join to create the string avoids this.

#19

… lot of 'concatenated string' elements on the heap, and consumes a lot more memory than a simple string needs. Using array.join to create the string avoids this.
@rupertlssmith
Copy link
Author

This might not yet be the most efficient way of doing this, but does solve the big problem of using way too much memory.

TextDecoder looks like it could work well, particularly for longer Strings, but will break Internet Explorer compatability (do we care??). Its unclear what the most efficient solution is without doing some benchmarking anyway.

See https://github.com/gren-lang/core/blob/main/src/Gren/Kernel/Bytes.js#L34 for usage example of TextDecoder on bytes.

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.

1 participant