On Thursday 2013-12-12 16:52 -0800, David Keeler wrote:
> Recently bug 539710 landed[0] to fix an unnecessary and apparently
> unsafe operation:
> 
> const PRUnichar *comma = NS_LITERAL_STRING(",").get();
> 
> Curious, I did a quick search for other examples of NS_LITERAL_STRING
> combined with .get() and found that this appears to be common[1].
> So, I have a few questions for anyone with some insight:
> - Is this pattern always unsafe?
> - Is it sometimes unsafe? (if so, when/why?)
> - Should we do some cleanup and avoid things like this? (or maybe this
> is an outdated concern and isn't an issue anymore?)

It used to be unsafe on platforms where we didn't use wide string
literals.

We've since dropped support for such platforms (in bug 904985), so
it's no longer unsafe.

However, given that we no longer support such platforms, it's also
a bunch of extra complexity that we no longer need.  The preferred
form would now be:

  #include "mozilla/Char16.h"

  const PRUnichar *comma = MOZ_UTF16(",");

-David

-- 
𝄞   L. David Baron                         http://dbaron.org/   𝄂
𝄢   Mozilla                          https://www.mozilla.org/   𝄂
             Before I built a wall I'd ask to know
             What I was walling in or walling out,
             And to whom I was like to give offense.
               - Robert Frost, Mending Wall (1914)

Attachment: signature.asc
Description: Digital signature

_______________________________________________
dev-platform mailing list
dev-platform@lists.mozilla.org
https://lists.mozilla.org/listinfo/dev-platform

Reply via email to