Implement the String.prototype.replaceAll proposal
Categories
(Core :: JavaScript: Standard Library, enhancement, P3)
Tracking
()
Tracking | Status | |
---|---|---|
firefox72 | --- | fixed |
People
(Reporter: afmenez, Assigned: anba)
References
(Blocks 1 open bug, )
Details
(Keywords: dev-doc-complete)
Attachments
(1 file)
The proposal is now on Stage 2.
Reporter | ||
Updated•7 years ago
|
Updated•7 years ago
|
Updated•7 years ago
|
Comment 1•6 years ago
|
||
The proposal advanced to stage 3 at today’s TC39 meeting.
Reporter | ||
Updated•6 years ago
|
Assignee | ||
Updated•6 years ago
|
Assignee | ||
Comment 2•6 years ago
|
||
This change doesn't include the String.prototype.matchAll modifications, because
those are already part of the main spec.
MCallOptimize.cpp:
- The inlining is more conservative than
inlineIsRegExpObject
, because it's not
clear at this point we need the extra features frominlineIsRegExpObject
.
String.js:
- The self-hosted part is slightly different than the current spec text, because
it combines the match and replace loops. The non-functional replace part is
implemented in C++, so we can reuse the existing C++ matcher functions.
String.cpp:
- Added some extra assertions to
AppendDollarReplacement
and also had to change
theinfallibleAppend
call into a normalappend
call, because when called
fromreplaceAll
, we may not have reserved enough space in the StringBuffer. replaceAll
has a specialised implementation when the pattern is the empty
string, because in that case the pattern is interleaved in-between each
character, so we don't need to find the next match and can also directly reserve
the correct string length (when no '$' characters are present in the replacement
string). This should allow users to update from the previous
str.split("").join(r)
pattern tostr.replaceAll("", r)
without loss of
performance.- When the pattern isn't the empty string, we reuse the existing
StringMatch
andAppendDollarReplacement
functions to match and replace the pattern.
This feature is still restricted to Nightly, because no test262 tests are
currently available.
Assignee | ||
Updated•6 years ago
|
Comment 4•6 years ago
|
||
bugherder |
Comment 5•6 years ago
|
||
Thanks for submitting this, André. We really appreciate it.
For info this has was shipped in Safari 13.1 [1].
Are there any blockers that prevent unflagging it in Firefox? (apart from MDN docs?)
[1] https://webkit.org/blog/10247/new-webkit-features-in-safari-13-1/#javascript-improvements
Assignee | ||
Comment 7•5 years ago
|
||
This ships in Firefox 77 (bug 1608168).
Comment 8•5 years ago
|
||
Docs:
https://developer.mozilla.org/en-US/docs/Mozilla/Firefox/Releases/77#JavaScript
https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/String/replaceAll
Updated•5 years ago
|
Description
•