RESOLVED FIXED 119335
Use emptyString instead of String("")
https://bugs.webkit.org/show_bug.cgi?id=119335
Summary Use emptyString instead of String("")
Kwang Yul Seo
Reported 2013-07-31 04:57:56 PDT
Use emptyString() instead of String("") because it is better style and faster. This is a followup to r116908, removing all occurrences of String("") from WebKit.
Attachments
Patch (11.71 KB, patch)
2013-07-31 05:01 PDT, Kwang Yul Seo
darin: review+
Kwang Yul Seo
Comment 1 2013-07-31 05:01:38 PDT
Kwang Yul Seo
Comment 2 2013-07-31 05:04:19 PDT
If we always prefer emptyString() to String(""), why don't we add an assertion to the String constructor to prevent "" from being passed to the constructor?
Darin Adler
Comment 3 2013-07-31 12:32:57 PDT
(In reply to comment #2) > If we always prefer emptyString() to String(""), why don't we add an assertion to the String constructor to prevent "" from being passed to the constructor? We don’t have any reason to allow String(""). But we do want to allow String(x) where x is a variable or argument of type const char* that just happens to be "".
Benjamin Poulain
Comment 4 2013-07-31 13:42:11 PDT
(In reply to comment #0) > Use emptyString() instead of String("") because it is better style and faster. This is a followup to r116908, removing all occurrences of String("") from WebKit. String("") is faster than emptyString() when you need a +1 ref string. emptyString() return a reference, which is then ref()ed on the call site. String("") does pretty much the same thing but ref() on the callee side. This is just for info, I don't mind if this patch lands.
Kwang Yul Seo
Comment 5 2013-07-31 16:51:21 PDT
(In reply to comment #4) > String("") is faster than emptyString() when you need a +1 ref string. > > emptyString() return a reference, which is then ref()ed on the call site. String("") does pretty much the same thing but ref() on the callee side. > > This is just for info, I don't mind if this patch lands. Thanks for the info. I think it is good to update the EfficientStrings wiki page.
Kwang Yul Seo
Comment 6 2013-07-31 16:53:04 PDT
Benjamin Poulain
Comment 7 2013-07-31 17:00:54 PDT
(In reply to comment #5) > Thanks for the info. I think it is good to update the EfficientStrings wiki page. We can also fix the problem. This https://bugs.webkit.org/show_bug.cgi?id=95793 needs an update.
Note You need to log in before you can comment on or make changes to this bug.