Several nsTLiteralString/nsTStringRepr member functions should be constexpr
Categories
(Core :: XPCOM, task)
Tracking
()
People
(Reporter: sg, Assigned: sg)
Details
(Keywords: leave-open)
Attachments
(2 files, 1 obsolete file)
Assignee | ||
Comment 1•1 year ago
|
||
This is easy for the member functions defined in the header, it is just necessary to add constexpr
.
It is also interesting for Equals
and Compare
, but the definitions of those functions need to be moved to the header as well. They could be implemented based on std::string_view, which already provides constexpr
comparison operators.
Assignee | ||
Comment 2•1 year ago
|
||
Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/bf906a905a26 Make member functions of nsTStringRepr defined in header constexpr. r=froydnj
Comment 4•1 year ago
|
||
Backed out changeset bf906a905a26 (Bug 1602452) for causing bustages in gtest/TestStrings.cpp
Backout link: https://hg.mozilla.org/integration/autoland/rev/0df1383a748325b5957d1dc5427eb772d434f4f8
Failure logs:
Assignee | ||
Updated•1 year ago
|
Assignee | ||
Comment 5•1 year ago
|
||
(In reply to Alexandru Michis [:malexandru] from comment #4)
Backed out changeset bf906a905a26 (Bug 1602452) for causing bustages in gtest/TestStrings.cpp
Windows build failures should be fixed by updated patch, running on try: https://treeherder.mozilla.org/#/jobs?repo=try&revision=ca71755198a7fa3bafe9b61c5aff4efecb74a1ec
Pushed by sgiesecke@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/2c6f4188a5bc Make member functions of nsTStringRepr defined in header constexpr. r=froydnj
Assignee | ||
Comment 7•1 year ago
|
||
Updated•1 year ago
|
Assignee | ||
Comment 8•1 year ago
|
||
Depends on D56682
Comment 9•1 year ago
|
||
bugherder |
Updated•1 year ago
|
Assignee | ||
Comment 10•1 year ago
|
||
After abandoning revision https://bugzilla.mozilla.org/attachment.cgi?id=9115096:
My original idea was to allow to write something like:
constexpr auto a = NS_LITERAL_STRING("a");
constexpr auto b = NS_LITERAL_STRING("b");
constexpr auto ab = a + b;
This would frequently be helpful. However, this is not possible since nsTSubstringTuple is a MOZ_TEMPORARY_CLASS. Alternatively, another overload of operator+ accepting only nsTLiteralString (or perhaps more explicitly a named function, e.g. ConcatConstexpr(...)) that allows to do this, could be defined, which doesn't return nsTSubstringTuple but a new class, which does not need to be MOZ_TEMPORARY_CLASS and might be based on an array rather than a binary tree. (I have done this in the past in another codebase.) What do you think about that?
Assignee | ||
Updated•1 year ago
|
Assignee | ||
Updated•7 months ago
|
![]() |
||
Comment 11•4 months ago
|
||
(In reply to Simon Giesecke [:sg] [he/him] from comment #10)
After abandoning revision https://bugzilla.mozilla.org/attachment.cgi?id=9115096:
My original idea was to allow to write something like:
constexpr auto a = NS_LITERAL_STRING("a"); constexpr auto b = NS_LITERAL_STRING("b"); constexpr auto ab = a + b;
This would frequently be helpful. However, this is not possible since nsTSubstringTuple is a MOZ_TEMPORARY_CLASS. Alternatively, another overload of operator+ accepting only nsTLiteralString (or perhaps more explicitly a named function, e.g. ConcatConstexpr(...)) that allows to do this, could be defined, which doesn't return nsTSubstringTuple but a new class, which does not need to be MOZ_TEMPORARY_CLASS and might be based on an array rather than a binary tree. (I have done this in the past in another codebase.) What do you think about that?
I am ambivalent on this, but it's not really my decision anymore. :)
Updated•1 month ago
|
Description
•