Closed
Bug 578257
Opened 14 years ago
Closed 13 years ago
Make date-format-xparb String.leftPad faster
Categories
(Core :: JavaScript Engine, defect)
Core
JavaScript Engine
Tracking
()
RESOLVED
WORKSFORME
People
(Reporter: dmandelin, Unassigned)
References
Details
The majority of our slowdown vs. JSC on date-format-xparb is in its function String.leftPad:
String.leftPad = function (val, size, ch) {
var result = new String(val);
if (ch == null) {
ch = " ";
}
while (result.length < size) {
result = ch + result;
}
return result;
}
I know JSC has optimizations for prepending to strings. A general prepend optimization may not be necessary. Other things that might work:
- have ropes speed this up somehow
- some kind of single-character prepend optimization
- some kind of optimization specific to the pattern in this padding function
JM wanted SS win: 15 ms
Comment 1•14 years ago
|
||
Looks like most of those milliseconds are spent in the call to new String(). Change
var result = new String(val);
to
var result = "" + val;
and you'll see it speed up by about 10ms.
It looks like the Add stub is wasting a lot of time calling js_DefaultValue, so that could explain the rest of the slowdown.
Comment 2•13 years ago
|
||
We've caught V8 and JSC on xparb, so I think we're done.
Status: NEW → RESOLVED
Closed: 13 years ago
Resolution: --- → WORKSFORME
You need to log in
before you can comment on or make changes to this bug.
Description
•