Closed Andrewangeta closed 6 years ago
Thanks for the attempt 👍 The reason I didn't accept it is because your solution makes a lot of copies.
If you initialize arrays from a sequence you're using the protocol's makeIterator()
and iterating over that iterator. This copies every byte one-by-one to the array (expanding the array many times). This results in a large performance loss since you're not copying the data in bulk. So the alternative code I posted (which was the intended version) expands the data once, and then copies the BufferPointer's data to there once which is really cheap.
Thanks for the help regardless! Hope the above helps you learn more about this!
No problem! Thanks for the explanation, we all want better performance.
@Obbut @Joannis Can you take a look when you get a chance. Fixes this compile issue.