Closed Bug 242577 Opened 20 years ago Closed 19 years ago

Maybe expose direct buffer manipulation in frozen string API

Categories

(Core :: XPCOM, enhancement)

enhancement
Not set
normal

Tracking

()

RESOLVED DUPLICATE of bug 288786
Future

People

(Reporter: darin.moz, Assigned: darin.moz)

Details

(Keywords: arch)

Maybe expose direct buffer manipulation in frozen string API.

To facilitate implementing functions like ToLowerCase using only the string API,
it might be good to expose a version of NS_StringGetData that returns a mutable
|PRUnichar*| buffer.  The new function would have a parameter that allows the
caller to specify the desired string length, e.g.:

NS_STRINGAPI(nsresult)
NS_StringGetDataMutable(nsAString &aStr, PRUint32 aDataLen, PRUnichar **aData);

I'm not sure I like this signature or name, but putting that issue aside for a
moment, this function would be implemented like this:

NS_StringGetDataMutable(nsAString &aStr, PRUint32 aDataLen, PRUnichar **aData)
{
  aStr->SetLength(aDataLen);

  nsAString::iterator iter;
  aStr->BeginWriting(iter);
  *aData = iter.get();

  return NS_OK;
}
Status: NEW → ASSIGNED
Target Milestone: --- → mozilla1.8alpha
Keywords: arch
Target Milestone: mozilla1.8alpha1 → Future

*** This bug has been marked as a duplicate of 288786 ***
Status: ASSIGNED → RESOLVED
Closed: 19 years ago
Resolution: --- → DUPLICATE
Component: String → XPCOM
You need to log in before you can comment on or make changes to this bug.