Stop using [array] in nsIPrefBranch
Categories
(Core :: Preferences: Backend, task)
Tracking
()
Tracking | Status | |
---|---|---|
firefox69 | --- | fixed |
People
(Reporter: bzbarsky, Assigned: bzbarsky)
References
(Blocks 1 open bug)
Details
Attachments
(2 files, 5 obsolete files)
![]() |
Assignee | |
Comment 1•6 years ago
|
||
![]() |
Assignee | |
Comment 2•6 years ago
|
||
Comment 3•6 years ago
|
||
Thanks, I'll take it from here. Looks like the JS changes are limited and the compiler will tell me if there's something wrong/missing in the C++ code.
Comment 5•6 years ago
|
||
How to best replace the qsort
here?
https://searchfox.org/comm-central/rev/a3437150e9d747de3eb28b4e45559ca32be7019c/mailnews/base/src/nsMsgTagService.cpp#352
Comment 6•6 years ago
|
||
This compiles, should be OK, but not sure about the qsort
. Maybe Nicholas is still around.
Comment 7•6 years ago
•
|
||
We have two "tag tests", comm/mailnews/base/test/unit/test_nsIMsgTagService.js, comm/mailnews/base/test/unit/test_searchTag.js. I'll run those when the compile is done.
EDIT: They crash :-(
Comment 8•6 years ago
|
||
In absence of a better solution for qsort
, let's copy the strings.
Comment 9•6 years ago
|
||
![]() |
Assignee | |
Comment 10•6 years ago
•
|
||
How to best replace the qsort here?
Sort()
on the nsTArray
. Looks like CompareMsgTagKeys
is a bog-standard lexicographic comparator, so you don't even need a custom comparator object, since strings define ==
and <
operators. Just do:
prefList.Sort();
and you're done.
![]() |
Assignee | |
Updated•6 years ago
|
Comment 11•6 years ago
|
||
Thanks, Boris, that does the trick.
![]() |
Assignee | |
Comment 12•6 years ago
|
||
Comment 13•6 years ago
|
||
Updated with latest comments, thanks, Boris. Less copying? Substring will copy, there's no way around it. And the search is the same, Rfind
and strrchr()
do the same thing in principal, no?
Any objection to
- char *info = strrchr(prefList[i], '.');
- if (info) {
- nsAutoCString key(Substring(prefList[i], info));
+ int32_t dotLoc = pref.RFindChar('.');
+ if (dotLoc != kNotFound) {
+ nsAutoCString key(Substring(pref, dotLoc));
instead of using the auto&
?
Comment 14•6 years ago
|
||
Hmm, something wrong here now, tests fail (also with auto&
as suggested). What's the difference between Substring
with a number and a char* argument? Strings in Mozilla, it will take me another 10 years to learn them :-(
Comment 15•6 years ago
|
||
Oh, apparently Substring
doesn't copy, so the auto&
is more efficient.
Comment 16•6 years ago
|
||
OK, the Substring()
was missing a 0. Now test pass.
Comment 17•6 years ago
|
||
bugherder |
Comment 18•6 years ago
|
||
bugherder |
Comment 19•6 years ago
|
||
![]() |
Assignee | |
Comment 20•6 years ago
|
||
Oh, right, Substring(ptr, ptr) returns that range... So you really wanted StringHead(pref, dotLoc).
Comment 21•6 years ago
|
||
Sigh, Mozilla strings, I hope we can survive with Substring(pref, 0, dotLoc)
. Looks like Substring
from 0 is used more frequently, maybe StringHead
is newer.
Comment 22•6 years ago
|
||
Description
•