<div dir="ltr"><div class="gmail_quote gmail_quote_container"><blockquote class="gmail_quote" style="margin:0px 0px 0px 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><div><p>I believe what you mean here is that if I have a string, and I
want to copy to a destination segment I could either:</p>
<p>* if the string buffer is compatible, just bulk-copy that buffer
into the target segment<br>
* if the string buffer is not compatible, encode the string
_directly_ into the target segment</p>
<p>Correct? If so, I tend to agree this would be slightly
preferrable, as we'd be touching things only once. And, I believe
this can be also done to the existing setString method?</p></div></blockquote><div>I think that's right, but I'd also gotten slightly confused. To try to restate:</div><div><br></div><div>setString assumes \0, which I touched on in the original mail about not being ideal if you want to write non-\0 terminated strings and the output buffer is perfectly sized.</div><div><br></div><div>In the case where the bytes aren't compatible, setString currently falls back to getBytes and then copies that into the destination segment. But I think it could be optimized to encode directly to the output without changing the API.</div><div><br></div><div>I had thought your proposal was to support the use-case of writing non-\0 terminated strings by using MS::ofString and then MS::copy, which I think would have equivalent performance to setString for the bytes compatible case, but might be more constrained for the case where the bytes aren't compatible. Had I misunderstood that part?</div></div></div>