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

Allocations when converting from integers/floats. #54

Open
rendarz opened this issue Jan 25, 2023 · 0 comments
Open

Allocations when converting from integers/floats. #54

rendarz opened this issue Jan 25, 2023 · 0 comments

Comments

@rendarz
Copy link

rendarz commented Jan 25, 2023

liquid-rust version:
rust version: 1.66.1
OS: Linux (Debian)

If I want to create a KString from a number, I have to do:
KString::from(123.to_string());

The problem with this code, is that it will create a String (which will always allocate memory) and then it will create a new KString out of that initial String, and so I guess that allocated memory will be destroyed if the resulting string from that number is small enough.
There is a way to avoid this memory allocation+deallocation, passing through a String, and having maybe some From and so on, which in turn will have a stack buffer so big to contain all integer/floats, so if the number fits in a KString without any allocation fine, otherwise it will allocate new memory for bigger numbers?

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

No branches or pull requests

1 participant