Closed Bug 1448581 Opened 6 years ago Closed 6 years ago

Avoid useless SIMD checks in CharacterData::ToCString

Categories

(Core :: DOM: Core & HTML, enhancement, P2)

enhancement

Tracking

()

RESOLVED FIXED
mozilla61
Tracking Status
firefox61 --- fixed

People

(Reporter: hsivonen, Assigned: hsivonen)

References

Details

Attachments

(1 file)

We append as ASCII buffer shorter than 16, so AppendASCIItoUTF16 is an overkill.
Comment on attachment 8962078 [details]
Bug 1448581 - Use AppendPrintf() in CharacterData::ToCString(). .

https://reviewboard.mozilla.org/r/230916/#review236746

Why don't we just

::: dom/base/CharacterData.cpp:430
(Diff revision 1)
>        } else if (ch == '>') {
>          aBuf.AppendLiteral(">");
>        } else if ((ch < ' ') || (ch >= 127)) {
>          char buf[10];
>          SprintfLiteral(buf, "\\u%04x", ch);
> -        AppendASCIItoUTF16(buf, aBuf);
> +        aBuf.AppendASCII(buf);

It'd be even cleaner if we just `aBuf.AppendPrintf("\\u%04x", ch);`.
Attachment #8962078 - Flags: review?(nika) → review+
Comment on attachment 8962078 [details]
Bug 1448581 - Use AppendPrintf() in CharacterData::ToCString(). .

https://reviewboard.mozilla.org/r/230916/#review236746

> It'd be even cleaner if we just `aBuf.AppendPrintf("\\u%04x", ch);`.

Thanks for pointing out the existence of that method! Fixed.
Pushed by hsivonen@mozilla.com:
https://hg.mozilla.org/integration/autoland/rev/729b8eb8a432
Use AppendPrintf() in CharacterData::ToCString(). r=mystor.
Priority: -- → P2
https://hg.mozilla.org/mozilla-central/rev/729b8eb8a432
Status: ASSIGNED → RESOLVED
Closed: 6 years ago
Resolution: --- → FIXED
Target Milestone: --- → mozilla61
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: