Port bug 1557793 - Adapt to array changes in nsIStringBundle.formatStringFrom{ID|Name|NameCpp}
Categories
(MailNews Core :: General, task)
Tracking
(Not tracked)
People
(Reporter: jorgk-bmo, Assigned: jorgk-bmo)
References
Details
Attachments
(3 files, 7 obsolete files)
(deleted),
patch
|
darktrojan
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
darktrojan
:
review+
|
Details | Diff | Splinter Review |
(deleted),
patch
|
jorgk-bmo
:
review+
Fallen
:
review+
|
Details | Diff | Splinter Review |
https://searchfox.org/comm-central/search?q=formatStringFrom&case=false®exp=false&path=*.cpp
About 40 files affected.
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 1•5 years ago
|
||
This fixed mailnews/addrbook/ - mach build comm/mailnews/addrbook/
More to come, of course.
Assignee | ||
Comment 2•5 years ago
|
||
This wasn't so much fun to write and it won't be fun to review. Let me know if I should find a TB reviewer. Some notes:
- Wherever the array isn't sized by initialising it, I used
AutoTArray<nsString, NN>
. I didn't see a pattern in D34196, there isAutoTArray<nsString, 1> strings = {path};
but alsonsTArray<nsString> formatStrings = {mHostPort};
. - I used
nsTArray<nsString>
when initialising the array. - In some cases, strings are passed in as raw strings or
nsAString&
. I usednsString(xx)
in this case to stuff them in to the format strings. Look fornsString(
in the patch. - I tried to remove as many "...toUTF16" conversions into temporary variables as possible.
- I didn't do the JS part yet.
Assignee | ||
Comment 3•5 years ago
|
||
Assignee | ||
Comment 4•5 years ago
|
||
Removed more temporary variables.
Comment 5•5 years ago
|
||
Wherever the array isn't sized by initialising it, I used AutoTArray<nsString, NN>. I didn't see a pattern in D34196, there is AutoTArray<nsString, 1> strings = {path}; but also nsTArray<nsString> formatStrings = {mHostPort};.
Should have been AutoTArray consistently; the nsTArray there is an oversight.
I used nsTArray<nsString> when initialising the array.
That's fine, but does an extra heap-allocation compared to using AutoTArray. Maybe it doesn't matter in practice, but it was easier for me to do the faster thing instead of analyzing all the callsites.
I didn't do the JS part yet.
The nice thing with the JS part is that if the C++ part lands without the JS part that's not a problem: the JS part will just be passing an extra arg for the length which will get ignored...
Comment 6•5 years ago
|
||
Oh, I did use nsTArray instead of AutoTArray in the one place where I std::move things, because nsTArray can be moved cheaply while AutoTArray of course cannot.
Comment 7•5 years ago
|
||
Assignee | ||
Comment 8•5 years ago
|
||
Thanks for the comment, Boris. I'll make it AutoTArray everywhere. We actually are in a separate bug here, I kept out of your bug 1557793 since I knew that this would create some noise :-)
One last question, is there a better way to do this:
const char16_t delimiter[2] = {(char16_t)m_hierarchyDelimiter, '\0'};
- const char16_t *formatStrings[] = {delimiter};
+ AutoTArray<nsString, 1> formatStrings = {nsDependentString(delimiter)};
EDIT: One very last question: How to deal with strings coming in as nsAString
, like so:
- const char16_t *formatStrings[] = {aAccountname.BeginReading()};
+ AutoTArray<nsString, 1> formatStrings = {PromiseFlatString(aAccountname)};
Assignee | ||
Comment 9•5 years ago
|
||
First reviewer wins. Note: This will land as bustage-fix as soon as bug 1557793 lands.
Assignee | ||
Comment 10•5 years ago
|
||
Another tweak.
Comment 11•5 years ago
|
||
One last question, is there a better way to do this:
AutoTArray<nsString, 1> formatStrings;
formatString.AppendElement(nsDependentSubstring(&m_hierarchyDelimiter, 1));
ought to work.
EDIT: One very last question: How to deal with strings coming in as nsAString, like so:
AutoTArray<nsString, 1> formatStrings;
formatString.AppendElement(aAccountname);
though you could also do:
AutoTArray<nsString, 1> formatStrings = {nsString(aAccountname)};
and it's probably equivalent in terms of the actual code that runs.
Assignee | ||
Comment 12•5 years ago
|
||
Thanks, Boris. The first solution doesn't work since m_hierarchyDelimiter is just a char*.
Assignee | ||
Comment 13•5 years ago
|
||
Final string tweak, first reviewer wins. Bug 1557793 has all the reviews and will land soon.
Assignee | ||
Comment 14•5 years ago
|
||
Sigh, there go another 100KB which will be stored for eternity. Forgot to refresh.
Comment 15•5 years ago
|
||
Thanks, Boris. The first solution doesn't work since m_hierarchyDelimiter is just a char*.
In that case, just:
AutoTArray<nsString, 1> formatStrings;
formatString.AppendElement()->Append(m_hierarchyDelimiter);
should work. (I assume you meant it's a char
, not a char *
.)
Assignee | ||
Comment 16•5 years ago
|
||
Assignee | ||
Comment 17•5 years ago
|
||
We still need to clean up about 25 .js files:
https://searchfox.org/comm-central/search?q=formatStringFrom&case=false®exp=false&path=*.js*
Comment 18•5 years ago
|
||
Assignee | ||
Updated•5 years ago
|
Assignee | ||
Comment 19•5 years ago
|
||
Comment 20•5 years ago
|
||
Comment 21•5 years ago
|
||
Updated•5 years ago
|
Comment 22•5 years ago
|
||
Assignee | ||
Comment 23•5 years ago
|
||
Assignee | ||
Comment 24•5 years ago
|
||
Thanks.
(In reply to Geoff Lankow (:darktrojan) from comment #21)
Missed this bit?
I'm surprised that compiled.
Assignee | ||
Updated•5 years ago
|
Comment 25•5 years ago
|
||
Pushed by mozilla@jorgk.com:
https://hg.mozilla.org/comm-central/rev/285cab894a6e
Follow-up: Address review comments. r=me
https://hg.mozilla.org/comm-central/rev/f7a7d54671d6
Port bug 1557793: Adapt to array changes in nsIStringBundle.formatStringFromName (JS changes). r=jorgk
Updated•5 years ago
|
Updated•5 years ago
|
Description
•