PRUint32 length = aReadable.Length(); CharT* buffer = new CharT[length]; if ( buffer ) {
basic_nsAWritableString<CharT>::AssignFromPromise( const nsPromiseReadable<CharT>& aReadable )    /*      ...this function is only called when a promise that somehow references |this| is assigned _into_ |this|.      E.g.,              ... writable& w ...        ... readable& r ...                w = r + w;      In this example, you can see that unless the characters promised by |w| in |r+w| are resolved before      anything starts getting copied into |w|, there will be trouble.  They will be overritten by the contents      of |r| before being retrieved to be appended.      We could have a really tricky solution where we tell the promise to resolve _just_ the data promised      by |this|, but this should be a rare case, since clients with more local knowledge will know that, e.g.,      in the case above, |Insert| could have special behavior with significantly better performance.  Since      it's a rare case anyway, we should just do the simplest thing that could possibly work, resolve the      entire promise.  If we measure and this turns out to show up on performance radar, we then have the      option to fix either the callers or this mechanism.    */  {    PRUint32 length = aReadable.Length();    CharT* buffer = new CharT[length];    if ( buffer )      {        // Note: not exception safe.  We need something to manage temporary buffers like this        copy_string(aReadable.BeginReading(), aReadable.EndReading(), buffer);        do_AssignFromElementPtrLength(buffer, length);        delete buffer;      }    // else assert?  }