Last Comment Bug 711841 - Add VoidString() or NullString() or NullDOMString()
: Add VoidString() or NullString() or NullDOMString()
Status: RESOLVED FIXED
:
Product: Core
Classification: Components
Component: String (show other bugs)
: unspecified
: x86_64 Linux
: -- normal (vote)
: mozilla12
Assigned To: Olli Pettay [:smaug] (reviewing overload)
:
:
Mentors:
Depends on:
Blocks:
  Show dependency treegraph
 
Reported: 2011-12-18 08:58 PST by Olli Pettay [:smaug] (reviewing overload)
Modified: 2011-12-21 11:58 PST (History)
4 users (show)
See Also:
Crash Signature:
(edit)
QA Whiteboard:
Iteration: ---
Points: ---
Has Regression Range: ---
Has STR: ---


Attachments
something like this (9.29 KB, patch)
2011-12-18 10:18 PST, Olli Pettay [:smaug] (reviewing overload)
mh+mozilla: review+
Details | Diff | Splinter Review

Description Olli Pettay [:smaug] (reviewing overload) 2011-12-18 08:58:34 PST
Atm, one needs to explicitly call SetIsVoid(). Would be nice to have something
close to EmptyString()
Comment 1 Olli Pettay [:smaug] (reviewing overload) 2011-12-18 09:12:53 PST
Something like
#define NullString() nsXPIDLString()
#define NullCString() nsXPIDLCString()
Comment 2 Olli Pettay [:smaug] (reviewing overload) 2011-12-18 09:51:08 PST
Or better to implement it like Empty(C)String
Comment 3 Olli Pettay [:smaug] (reviewing overload) 2011-12-18 10:18:39 PST
Created attachment 582680 [details] [diff] [review]
something like this

Since nsXPIDLString has the behavior anyway, we should be able to reuse that.

https://tbpl.mozilla.org/?tree=Try&rev=ec49c8378fd2
Comment 4 Boris Zbarsky [:bz] (still a bit busy) 2011-12-18 12:45:26 PST
SetDOMStringToNull exists.
Comment 5 Olli Pettay [:smaug] (reviewing overload) 2011-12-18 12:57:38 PST
This is not about a method which sets a string to null, but having a null string, which can be easily passed as a parameter to methods, or used in ctor member initialization.
Comment 6 Benjamin Smedberg [:bsmedberg] 2011-12-20 06:47:49 PST
Comment on attachment 582680 [details] [diff] [review]
something like this

glandium, will this cause a static ctor to run, and do you think that's a profile? Otherwise I think this is fine.
Comment 7 Mike Hommey [:glandium] 2011-12-20 07:23:34 PST
The patch as is won't cause a static ctor, but will cause a mutex being used each time NullString and NullCString are used.
Comment 8 Olli Pettay [:smaug] (reviewing overload) 2011-12-20 07:47:22 PST
IRC:
glandium >	smaug: mmm actually looking at the code gcc generates, it only acquires the lock if it the constant wasn't already initialized, so it's not as bad as i suggested

That doesn't sound bad to me, and EmptyString has the same behavior.
Comment 9 Mike Hommey [:glandium] 2011-12-20 11:45:01 PST
Comment on attachment 582680 [details] [diff] [review]
something like this

rs=me
Comment 10 Olli Pettay [:smaug] (reviewing overload) 2011-12-20 13:59:16 PST
https://hg.mozilla.org/mozilla-central/rev/3328809425d2

Note You need to log in before you can comment on or make changes to this bug.