Closed
Bug 1613564
Opened 4 years ago
Closed 4 years ago
Rust nsACString should be able to produce a String without copying
Categories
(Core :: XPCOM, task)
Core
XPCOM
Tracking
()
RESOLVED
INCOMPLETE
People
(Reporter: zbraniecki, Assigned: emilio)
References
Details
Attachments
(1 file, 1 obsolete file)
Came up while working on bug 1560038.
From :emilio on #rust on Matrix:
zbraniecki: but then you want a no-copy way to turn that nsACString into a String
zbraniecki: and I'm not sure we have that... But it seems conceptually possible
zbraniecki: I think we should be able to add an nsCString::into_string(self) or such
Assignee | ||
Updated•4 years ago
|
Flags: needinfo?(emilio)
Comment 1•4 years ago
|
||
There are ~4 things that an nsACString
can represent:
- A fully owned
char*
buffer. - A
char*
that points into data that somebody else owns. - A
char*
that points at astatic char[]
(which is really a special case of number 2). - An
nsStringBuffer
object (potentially) shared by othernsACString
objects.
So you can really only do this in a zero-copy way for the first representation. If you're OK with that limitation (and realizing that--at least in the C++ code--most strings are probably using the last representation), I guess the API makes sense?
Assignee | ||
Comment 2•4 years ago
|
||
Yes, this would need to return an Option
or a Cow
or something... For Zibi's purposes I think (1) is the case he'll hit.
Assignee | ||
Comment 3•4 years ago
|
||
Updated•4 years ago
|
Assignee: nobody → emilio
Status: NEW → ASSIGNED
Assignee | ||
Comment 4•4 years ago
|
||
Depends on D63968
Assignee | ||
Updated•4 years ago
|
Flags: needinfo?(emilio)
Pushed by ealvarez@mozilla.com: https://hg.mozilla.org/integration/autoland/rev/c123ce0ac63c Minor nsstring cleanup / tweaks. r=froydnj
Updated•4 years ago
|
Attachment #9128648 -
Attachment is obsolete: true
Comment 7•4 years ago
|
||
bugherder |
Reporter | ||
Comment 8•4 years ago
|
||
should we close this now?
Assignee | ||
Comment 9•4 years ago
|
||
Probably.
Status: ASSIGNED → RESOLVED
Closed: 4 years ago
Resolution: --- → INCOMPLETE
Updated•4 years ago
|
Keywords: leave-open
You need to log in
before you can comment on or make changes to this bug.
Description
•