Bug 87847

Summary: [Qt] Make conversion from QString to WTF::String (and back again) ~free
Product: WebKit Reporter: Tor Arne Vestbø <vestbo>
Component: New BugsAssignee: Tor Arne Vestbø <vestbo>
Status: RESOLVED FIXED    
Severity: Normal CC: barraclough, cmarcelo, darin, hausmann, zalan
Priority: P2    
Version: 528+ (Nightly build)   
Hardware: Unspecified   
OS: Unspecified   
Attachments:
Description Flags
Patch
none
Patch
none
Patch
none
Patch
none
Patch barraclough: review+

Description Tor Arne Vestbø 2012-05-30 06:33:28 PDT
[Qt] Make conversion from QString to WTF::String (and back again) ~free
Comment 1 Tor Arne Vestbø 2012-05-30 06:35:39 PDT
Created attachment 144794 [details]
Patch
Comment 2 Tor Arne Vestbø 2012-05-30 06:54:38 PDT
Created attachment 144800 [details]
Patch
Comment 3 Tor Arne Vestbø 2012-05-30 06:59:59 PDT
Created attachment 144803 [details]
Patch
Comment 4 Tor Arne Vestbø 2012-05-30 07:24:55 PDT
Created attachment 144808 [details]
Patch
Comment 5 Simon Hausmann 2012-05-30 07:37:41 PDT
Comment on attachment 144808 [details]
Patch

I think this looks good from a Qt perspective. I think we should run the idea also past some other String folks, to see if they have any concerns with doing this Qt specific optimization.
Comment 6 zalan 2012-05-30 07:39:57 PDT
Comment on attachment 144808 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=144808&action=review

> w/Source/WTF/wtf/text/StringImpl.h:406
> +    QStringData* qStringData() { return bufferOwnership() == BufferAdoptedQString ? m_qStringData : 0; }

shouldnt m_qStringData be NULL anyway when it's not adoptedQString?
Comment 7 Simon Hausmann 2012-05-30 07:42:46 PDT
Comment on attachment 144808 [details]
Patch

View in context: https://bugs.webkit.org/attachment.cgi?id=144808&action=review

>> w/Source/WTF/wtf/text/StringImpl.h:406
>> +    QStringData* qStringData() { return bufferOwnership() == BufferAdoptedQString ? m_qStringData : 0; }
> 
> shouldnt m_qStringData be NULL anyway when it's not adoptedQString?

It could have a different value since it's part of a union.
Comment 8 zalan 2012-05-30 07:49:15 PDT
(In reply to comment #7)
> (From update of attachment 144808 [details])
> View in context: https://bugs.webkit.org/attachment.cgi?id=144808&action=review
> 
> >> w/Source/WTF/wtf/text/StringImpl.h:406
> >> +    QStringData* qStringData() { return bufferOwnership() == BufferAdoptedQString ? m_qStringData : 0; }
> > 
> > shouldnt m_qStringData be NULL anyway when it's not adoptedQString?
> 
> It could have a different value since it's part of a union.

oh right. that was cut off of the review context. should have looked at the original code.
Comment 9 Tor Arne Vestbø 2012-05-30 07:50:02 PDT
(In reply to comment #5)
> (From update of attachment 144808 [details])
> I think this looks good from a Qt perspective. I think we should run the idea also past some other String folks, to see if they have any concerns with doing this Qt specific optimization.

Come to think of it, if more ports would like this we can always make the ownership BufferAdoptedPlatformString instead.
Comment 10 Early Warning System Bot 2012-05-30 09:03:01 PDT
Comment on attachment 144808 [details]
Patch

Attachment 144808 [details] did not pass qt-wk2-ews (qt):
Output: http://queues.webkit.org/results/12842890
Comment 11 Tor Arne Vestbø 2012-05-31 07:40:12 PDT
Created attachment 145089 [details]
Patch

Rebased to ToT, HAVE(QT5) landed in r119098
Comment 12 Tor Arne Vestbø 2012-05-31 07:41:45 PDT
Darin, Gavin, what do you guys think?
Comment 13 Gavin Barraclough 2012-05-31 15:35:47 PDT
Comment on attachment 145089 [details]
Patch

This seems fine to me.  We've discussed refactoring the various backing buffers behind an extra layer of abstraction at some point, with a virtual interface so we can move knowledge of the set of supported types out of backing buffers out of StringImpl.  But if we do want to make a change like that, we could easily make QStringData one of the types of supported buffers.
Comment 14 Tor Arne Vestbø 2012-06-01 05:26:04 PDT
Committed r119217: <http://trac.webkit.org/changeset/119217>