UString::create() creates a copy of the UChar* passed, but UStringImpl::create() assumes that it should assume ownership of the provided buffer (with UString::createNonCopying() and UStringImpl::createCopying() providing the alternate behaviours). Unify on create() taking a copy of the provided buffer. For non-copying cases, use the name 'adopt', and make this method take a Vector<UChar>&. For cases where non-copying construction was being used, other than from a Vector<UChar>, change the code to allocate the storage along with the UStringImpl using UStringImpl::createUninitialized(). (The adopt() method also more closely matches that of WebCore::StringImpl).
Also, UString::createUninitialized() and UStringImpl::createUninitialized() have incompatible behaviours, in that the UString form sets the provided UChar* to a null or non-null value to indicate success or failure, but UStringImpl uses the returned PassRefPtr<UStringImpl> to indicate when allocation has failed (potentially leaving the output Char* uninitialized). This is also incompatible with WebCore::StringImpl's behaviour, in that StringImpl::createUninitialized() will CRASH() if unable to allocate. Some uses of createUninitialized() in JSC are unsafe, since they do not test the result for null. UStringImpl's indication is preferable, since we may want a successful call to set the result buffer to 0 (specifically, StringImpl returns 0 for the buffer where createUninitialized() returns the empty string, which seems reasonable to catch bugs early). UString's method cannot support UStringImpl's behaviour directly, since it returns an object rather than a pointer.
- remove UString::createUninitialized(), replace with calls to UStringImpl::createUninitialized()
- create a UStringImpl::tryCreateUninitialized() form UStringImpl::createUninitialized(), with current behaviour, make createUninitialized() crash on failure to allocate.
- make cases in JSC that do not check the result call createUninitialized(), and cases that do check call tryCreateUninitialized().
Rename computedHash() to existingHash(), to bring this in line wih WebCore::StringImpl.
Created attachment 46632 [details]
Attachment 46632 [details] did not pass style-queue:
Failed to run "WebKitTools/Scripts/check-webkit-style" exit_code: 1
Total errors found: 3
Attachment 46632 [details] did not build on mac:
Build output: http://webkit-commit-queue.appspot.com/results/187794
fixed in r53320
Looks like this broke the Windows build:
At least the Debug build, or so http://build.webkit.org/console thinks.
I think this is the error:
WebCore_debug.lib(XMLHttpRequest.obj) : error LNK2019: unresolved external symbol "public: static class JSC::UString __cdecl JSC::UString::createNonCopying(wchar_t *,int)" (?createNonCopying@UString@JSC@@SA?AV12@PA_WH@Z) referenced in function "public: class JSC::UString __thiscall JSC::StringBuilder::release(void)" (?release@StringBuilder@JSC@@QAE?AVUString@2@XZ)
Sadly we don't have a Windows EWS bot yet.
I'm aware of this & can't see what is causing it – I think it might just be something stale on the bot, I'm going to email brian & ask him to give it a kick in the morning.