Closed figuerom16 closed 10 months ago
The append implementation strangely works just not the original version.
Ok, I think I understand what's going on now! So no matter what the buffer needs to copied every time which is what append is doing essentially. If something modifies the buffer in t.handleOutput then it will be corrupted upon return.
Unless we hunt down what's changing the buffer in t.handleOutput it will need to be copied every time. EDIT: If I had to guess it might be utf8.DecodeRune(buf) doing something to the buffer memory. I don't see an easy way around that though.
This is the best/simplest implementation I can find. Luckily it's simpler than the previous implementation. Someone who is more knowledgeable about buffer handling can probably optimize this. Sorry, I couldn't remove the buffer copy.
Increased buffer size to 32KB to fit in most L1 cache the 4KB buffer is an old I/O standard for files on old hardware. This will reduce refreshes and buffer copies.
Buffer corruption was still happening
due to the use of Append instead of Copy. Copy is more precise.I've tried to make an if statement to skip the Copying on when leftover is length zero, but for some reason it always adds back in corruption. I'm really not sure why other than deeper memory handling that I'm not seeing.