Closed Bug 1142814 Opened 9 years ago Closed 9 years ago

Optimize String.fromCharCode() when the number of args is small but > 1

Categories

(Core :: JavaScript Engine, defect)

defect
Not set
normal

Tracking

()

RESOLVED FIXED
mozilla39
Tracking Status
firefox39 --- fixed

People

(Reporter: n.nethercote, Assigned: n.nethercote)

Details

Attachments

(1 file)

Shumway calls String.fromCharCode() with two arguments frequently, and this
does an unnecessary malloc that can be avoide easily..
Comment on attachment 8577005 [details] [diff] [review]
Optimize String.fromCharCode() when the number of args is small but > 1

Review of attachment 8577005 [details] [diff] [review]:
-----------------------------------------------------------------

Avoiding malloc is always nice.

::: js/src/jsstr.cpp
@@ +4031,5 @@
> +    for (unsigned i = 0; i < args.length(); i++) {
> +        uint16_t code;
> +        if (!ToUint16(cx, args[i], &code)) {
> +            return false;
> +        }

Nit: no {}

@@ +4037,5 @@
> +    }
> +    JSString *str = NewStringCopyN<CanGC>(cx, chars, args.length());
> +    if (!str) {
> +        return false;
> +    }

And here.
Attachment #8577005 - Flags: review?(jdemooij) → review+
Somehow I accidentally incorporated some unrelated and broken changes to JSDOMParser.js in my first push. Relanding without those changes:

https://hg.mozilla.org/integration/mozilla-inbound/rev/24640e5e0d3d
Flags: needinfo?(n.nethercote)
https://hg.mozilla.org/mozilla-central/rev/24640e5e0d3d
Status: ASSIGNED → RESOLVED
Closed: 9 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla39
Please see https://bugzilla.mozilla.org/show_bug.cgi?id=1144081 for a regression problem that might be caused by this patch.
(In reply to Gary [:streetwolf] from comment #7)
> Please see https://bugzilla.mozilla.org/show_bug.cgi?id=1144081 for a
> regression problem that might be caused by this patch.

(Commented there. Other bugs in that range seem more likely than this one.)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: