Summary: | Use emptyString() instead of "" when possible | ||||||
---|---|---|---|---|---|---|---|
Product: | WebKit | Reporter: | Chris Dumez <cdumez> | ||||
Component: | WebCore Misc. | Assignee: | Chris Dumez <cdumez> | ||||
Status: | RESOLVED FIXED | ||||||
Severity: | Normal | CC: | achristensen, commit-queue, esprehn, kling, koivisto | ||||
Priority: | P2 | ||||||
Version: | WebKit Nightly Build | ||||||
Hardware: | Unspecified | ||||||
OS: | Unspecified | ||||||
Attachments: |
|
Description
Chris Dumez
2016-07-14 15:15:26 PDT
Created attachment 283691 [details]
Patch
Comment on attachment 283691 [details] Patch Clearing flags on attachment: 283691 Committed r203250: <http://trac.webkit.org/changeset/203250> All reviewed patches have been landed. Closing bug. Does this actually save allocations? String("") does StringImpl::create(LChar*) which does strlen and then StringImpl::create(LChar*, unsigned) which does: https://github.com/adobe/webkit/blob/master/Source/WTF/wtf/text/StringImpl.cpp#L255 if (!characters || !length) return empty(); I think this patch saves branches and function calls, but not allocations? (In reply to comment #4) > Does this actually save allocations? String("") does > StringImpl::create(LChar*) which does strlen and then > StringImpl::create(LChar*, unsigned) which does: > > https://github.com/adobe/webkit/blob/master/Source/WTF/wtf/text/StringImpl. > cpp#L255 > > if (!characters || !length) > return empty(); > > I think this patch saves branches and function calls, but not allocations? You're totally right Elliot, I did not know about this optimization in StringImpl. |