Skip to content

String buf#924

Open
HEIHUAa wants to merge 5 commits intoCodenameCrew:mainfrom
HEIHUAa:StringBuf
Open

String buf#924
HEIHUAa wants to merge 5 commits intoCodenameCrew:mainfrom
HEIHUAa:StringBuf

Conversation

@HEIHUAa
Copy link
Contributor

@HEIHUAa HEIHUAa commented Mar 19, 2026

Use StringBuf to reduce memory overhead from string concatenation.

Copy link
Contributor

@r6915ee r6915ee left a comment

Choose a reason for hiding this comment

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

I'm noticing that the way the buffer is modified is done using large sections of code that can consist of up to ten lines using just the add method. I'd personally recommend iterating through every modification and applying it that way.

var buf:StringBuf = new StringBuf();
for (i in ["prefix", data, "suffix"])
    buf.add(i);

@HEIHUAa
Copy link
Contributor Author

HEIHUAa commented Mar 20, 2026

for (i in ["prefix", data, "suffix"])

Actually, in the for (i in ["prefix", data, "suffix"]) operation, the [] creates a new array, allocating new memory.

@HEIHUAa
Copy link
Contributor Author

HEIHUAa commented Mar 20, 2026

I ended up writing a macro for this. It might make the code look a bit bloated, but it's definitely better than the previous approach. Of course, if there's a better way, feel free to let me know.

@Raltyro Raltyro added type:enhancement New feature or request status:awaiting Awaiting response by creator of issue status:planned This is planned to happen labels Mar 20, 2026
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

status:awaiting Awaiting response by creator of issue status:planned This is planned to happen type:enhancement New feature or request

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants