Open Bug 1662251 Opened 5 years ago Updated 4 years ago

do a better job with NS_ConvertUTF*toUTF*

Categories

(Core :: XPCOM, task)

task

Tracking

()

Tracking Status
firefox82 --- wontfix

People

(Reporter: froydnj, Unassigned)

Details

Attachments

(2 files)

We sometimes use inefficient code around these classes (not functions!). This is about fixing up all the places that are easily automatable.

This patch was generated by running:

perl -p -i \
     -e 's/^(\s+)([a-zA-Z0-9.]+) = NS_ConvertUTF8toUTF16\((.*)\);/\1CopyUTF8toUTF16(\3, \2);/;' \
     -e 's/^(\s+)([a-zA-Z0-9.]+) = NS_ConvertUTF16toUTF8\((.*)\);/\1CopyUTF16toUTF8(\3, \2);/;' \
     $FILE

against every .cpp and .h in mozilla-central, and then fixing up the
inevitable errors that happen as a result of matching C++ expressions with
regexes. The errors fell into three categories:

  1. Calling the convert functions with std::string::c_str(); these were
    changed to simply pass the string instead, relying on implicit conversion
    to mozilla::Span.
  2. Calling the convert functions with raw pointers, which is not permitted
    with the copy functions; these were changed to invoke MakeStringSpan first.
  3. Other miscellaneous errors resulting from over-eager regexes and/or the
    replacement not being type-aware. These changes were reverted.
Assignee: nobody → nfroyd
Status: NEW → ASSIGNED

Instead of initialization with an object of type NS_ConvertUTF*, we can
just declare an object with that type to begin with.

Depends on D88903

Pushed by nfroyd@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/0889462c340f stop assigning from NS_Convert* values, mostly; r=sg
Status: ASSIGNED → RESOLVED
Closed: 5 years ago
Resolution: --- → FIXED
Target Milestone: --- → 82 Branch

One patch landed, but one is still open. I might commandeer that revision to myself, but it should probably be moved to a new bug.

Status: RESOLVED → REOPENED
Flags: needinfo?(sgiesecke)
Resolution: FIXED → ---
Component: XPCOM → String
Flags: needinfo?(sgiesecke)
Flags: needinfo?(sgiesecke)
Component: String → XPCOM
Assignee: froydnj+bz → nobody
Status: REOPENED → NEW
Target Milestone: 82 Branch → ---
Flags: needinfo?(sgiesecke)
You need to log in before you can comment on or make changes to this bug.

Attachment

General

Created:
Updated:
Size: