Re: Extending the length of an XPCOM string when writing to it via a raw pointer

2018-08-31 Thread Henri Sivonen
On Fri, Aug 31, 2018 at 8:43 AM, Henri Sivonen wrote: > At this point, it's probably relevant to mention that SetCapacity() in > situations other that ahead of a sequence of Append()s is most likely > wrong (and has been so since at least 2004; I didn't bother doing code > archeology further back

Re: Extending the length of an XPCOM string when writing to it via a raw pointer

2018-08-30 Thread Henri Sivonen
On Thu, Aug 30, 2018 at 7:43 PM, Henri Sivonen wrote: >> What is then the point of SetCapacity anymore? > > To avoid multiple allocations during a sequence of Append()s. (This is > documented on the header.) At this point, it's probably relevant to mention that SetCapacity() in situations other

Re: Extending the length of an XPCOM string when writing to it via a raw pointer

2018-08-30 Thread Henri Sivonen
On Thu, Aug 30, 2018 at 6:00 PM, smaug wrote: > On 08/30/2018 11:21 AM, Henri Sivonen wrote: >> >> We have the following that a pattern in our code base: >> >> 1) SetCapacity(newCapacity) is called on an XPCOM string. >> 2) A pointer obtained from BeginWriting() is used for writing more >>

Re: Extending the length of an XPCOM string when writing to it via a raw pointer

2018-08-30 Thread smaug
On 08/30/2018 11:21 AM, Henri Sivonen wrote: We have the following that a pattern in our code base: 1) SetCapacity(newCapacity) is called on an XPCOM string. 2) A pointer obtained from BeginWriting() is used for writing more than Length() but no more than newCapacity code units to the XPCOM

Extending the length of an XPCOM string when writing to it via a raw pointer

2018-08-30 Thread Henri Sivonen
We have the following that a pattern in our code base: 1) SetCapacity(newCapacity) is called on an XPCOM string. 2) A pointer obtained from BeginWriting() is used for writing more than Length() but no more than newCapacity code units to the XPCOM string. 3) SetLength(actuallyWritten) is