Closed Bug 1390428 Opened 7 years ago Closed 7 years ago

Remove nsXPIDLCString

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla57
Tracking Status
firefox57 --- fixed

People

(Reporter: n.nethercote, Assigned: n.nethercote)

References

Details

Attachments

(10 files)

50.95 KB, patch
erahm
: review+
Details | Diff | Splinter Review
65.57 KB, patch
erahm
: review+
Details | Diff | Splinter Review
5.46 KB, patch
erahm
: review+
Details | Diff | Splinter Review
8.83 KB, patch
erahm
: review+
Details | Diff | Splinter Review
11.63 KB, patch
erahm
: review+
Details | Diff | Splinter Review
3.96 KB, patch
erahm
: review+
Details | Diff | Splinter Review
4.25 KB, patch
erahm
: review+
Details | Diff | Splinter Review
965 bytes, patch
erahm
: review+
Details | Diff | Splinter Review
70.93 KB, patch
erahm
: review+
Details | Diff | Splinter Review
929 bytes, patch
jorgk-bmo
: review+
Details | Diff | Splinter Review
Let's remove nsXPIDLCString.
These are all easy cases where an nsXPIDLCString local variable is set via
getter_Copies() and then is only used in ways that nsCStrings can also be used
(i.e. no null checks or implicit conversions to |char*|).

In every case the patch trivially replaces the nsXPIDLCString with an
nsCString. (Also, there are a couple of unused nsXPIDLCString variables that
the patch simply removes.)
Attachment #8897353 - Flags: review?(erahm)
These are all easy cases where an nsXPIDLCString local variable is set via
getter_Copies() and then is used in ways that rely on the implicit conversion
to |char*|. The patch uses get() and EqualsLiteral() calls to replace the
implicit conversions.
Attachment #8897355 - Flags: review?(erahm)
Most of these fields are not using any nsXPIDLCString-specific features.
The exceptions are mUserAgentOverride and mDefaultSocketType, which require a
little more care.
Attachment #8897356 - Flags: review?(erahm)
These are all easy cases where an nsXPIDLCString local variable is set via
getter_Copies() and then is null checked. The patch uses IsVoid() to replace
the null checks (and get() and EqualsLiteral() calls to replace any implicit
conversions).
Attachment #8897358 - Flags: review?(erahm)
These are all simple cases, with similarities to previous patches in this
series.
Attachment #8897359 - Flags: review?(erahm)
Attachment #8897353 - Flags: review?(erahm) → review+
Attachment #8897355 - Flags: review?(erahm) → review+
Attachment #8897356 - Flags: review?(erahm) → review+
Attachment #8897358 - Flags: review?(erahm) → review+
Comment on attachment 8897359 [details] [diff] [review]
(part 5) - Remove more nsXPIDLCString uses

Review of attachment 8897359 [details] [diff] [review]:
-----------------------------------------------------------------

r+ with minor nits addressed

::: xpfe/components/directory/nsDirectoryViewer.cpp
@@ +741,2 @@
>    GetDestination(r, uri);
> +  return uri.get() && !strncmp(uri.get(), kFTPProtocol, sizeof(kFTPProtocol) - 1) &&

a) Should this be `!uri.IsVoid()`? I thought we always used empty string internally, but I'm might be recalling incorrectly
b) We could just use `StringBeginsWith(uri, NS_LITERAL_CSTRING(kFTPProtocol)` now

@@ +936,5 @@
>        if (source) {
>          httpIndex->GetDestination(source, uri);
>        }
>  
> +      if (!uri.get()) {

Same question about IsVoid
Attachment #8897359 - Flags: review?(erahm) → review+
> > +  return uri.get() && !strncmp(uri.get(), kFTPProtocol, sizeof(kFTPProtocol) - 1) &&
> 
> a) Should this be `!uri.IsVoid()`? I thought we always used empty string
> internally, but I'm might be recalling incorrectly
> b) We could just use `StringBeginsWith(uri,
> NS_LITERAL_CSTRING(kFTPProtocol)` now

Yes and yes! Good catches, thank you.

> > +      if (!uri.get()) {
> 
> Same question about IsVoid

Correct here, too.
Keywords: leave-open
These are all straightforward except for InternalLoadEvent::mTypeHint, which
requires a bit of care to preserve existing behaviour.
Attachment #8898145 - Flags: review?(erahm)
The existing comment was very helpful here.
Attachment #8898146 - Flags: review?(erahm)
This change makes NullCString() work the same way as NullString().
Attachment #8898147 - Flags: review?(erahm)
This is straightforward, with only two notable things.

- `#include "nsXPIDLString.h" is replaced with `#include "nsString.h"`
  throughout, because all nsXPIDLString.h did was include nsString.h. The
  exception is for files which already include nsString.h, in which case the
  patch just removes the nsXPIDLString.h inclusion.

- The patch removes the |xpidl_string| gtest, but improves the |voided| test to
  cover some of its ground, e.g. testing Adopt(nullptr).
Attachment #8898148 - Flags: review?(erahm)
(In reply to Nicholas Nethercote [:njn] from comment #14)
> https://hg.mozilla.org/integration/mozilla-inbound/rev/
> fbf0e8609abb4b978070dd0cbfcab6de7b2cda73
> Bug 1390428 (part 2) - Remove more nsXPIDLCString local variables. r=erahm.

Backed out for various Windows clipboard test failures (Win7/Win8, all flavors).
https://hg.mozilla.org/integration/mozilla-inbound/rev/d2571908d00cad44be3fc9dcc14426060b8b0a77

https://treeherder.mozilla.org/logviewer.html#?job_id=124096377&repo=mozilla-inbound
Flags: needinfo?(n.nethercote)
Attachment #8898145 - Flags: review?(erahm) → review+
Attachment #8898146 - Flags: review?(erahm) → review+
Attachment #8898147 - Flags: review?(erahm) → review+
Comment on attachment 8898148 [details] [diff] [review]
(part 9) - Remove nsXPIDLCString

Review of attachment 8898148 [details] [diff] [review]:
-----------------------------------------------------------------

\o/
Attachment #8898148 - Flags: review?(erahm) → review+
https://hg.mozilla.org/integration/mozilla-inbound/rev/cc8e481fd0e16fba17ab6786a3f5212ab814c0e9
Bug 1390428 (part 2, attempt 2) - Remove more nsXPIDLCString local variables. r=erahm.
I updated https://developer.mozilla.org/en-US/docs/Mozilla/Tech/XPCOM/Guide/Internal_strings to remove all mentions of nsXPIDL[C]String.
Flags: needinfo?(n.nethercote)
Keywords: leave-open
Should this still have the 'leave-open' keyword?
Flags: needinfo?(n.nethercote)
> Should this still have the 'leave-open' keyword?

I had already removed it. But thank you for paying attention :)
Flags: needinfo?(n.nethercote)
Comment on attachment 8900559 [details] [diff] [review]
Remove unused nsXPIDLString.h inclusion

Thanks.
Attachment #8900559 - Flags: review?(jorgk) → review+
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/56c3a9e0cbda
Remove unused nsXPIDLString.h inclusion. r=jorgk
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: