4coder » Forums » How to use stream_chunk
boagz57
Jason
105 posts
#17373 How to use stream_chunk
6 months, 1 week ago Edited by Jason on Feb. 8, 2019, 1:46 a.m. Reason: Initial post

I'm trying to learn the ins and outs of 4coder and was wondering if someone could explain the use of stream_chunks. Do they just provide more convenient ways to work with buffers? What is their main purpose and when would you use them?
Mr4thDimention
Allen Webster
473 posts / 2 projects

Heyo

#17378 How to use stream_chunk
6 months, 1 week ago

The stream chunk stuff is an optimization helper for reading buffers. You can achieve the same thing as they achieve by reading in the entire buffer into your own memory and scanning through that, or by reading the buffer one character at a time, but each of these options is sub-optimal for certain commands. Each individual read has some overhead so lots of one character reads means the overhead adds up, but reading in an entire 10K of text when you're most likely to find what you need in 100 or 200 characters means you're doing an extra big memory copy. Really 99% of the time you could just do one of the slower methods though and it would be fine. I only tried to do most things in the streaming system so that I had some examples of streams in the custom layer.
boagz57
Jason
105 posts
#17383 How to use stream_chunk
6 months, 1 week ago

Gotcha. Thank you.

P.S. Just bought the editor the other day and I'm loving it. You've done an excellent job.