On 10/01/2012 11:40 AM, Noel Grandin wrote:
On 2012-10-01 10:15, Stephan Bergmann wrote:
Note that the rtl string functionality had originally been designed,
arguably somewhat naively, after java.lang.String.  On the Java
platform, immutability of String is an important security measure.
While that argument is irrelevant in a C/C++ context, immutability is
also an important concept when reasoning about multi-threaded code.
Therefore, the distinction between OUString and OUStringBuffer IMO
does make sense after all.

I don't see how the design helps you in a multithreaded context.
If you share an OUString instance between two threads, either thread
could assign to it, replacing it's contents, and invalidating what the
other thread sees.
So it's really not any safer than using an OUStringBuffer.
It just gives the illusion of safety.

Ach, I hadn't been sufficiently coffeeinated yet. My mind had somehow been fogged into assuming that

  void f(OUString const & s) {
    // use s here without fear of concurrent modification
  }

was correct---which, of course, it is not.

So, yes, the design of the rtl string functionality is not only somewhat naive. (I faintly remember having written about that before, back in OOo times, but that's likely lost.)

Stephan
_______________________________________________
LibreOffice mailing list
LibreOffice@lists.freedesktop.org
http://lists.freedesktop.org/mailman/listinfo/libreoffice

Reply via email to