RESOLVED FIXED 100667
[EFL][WK2] Avoid useless assignment in EwkViewImpl::setCustomTextEncodingName()
https://bugs.webkit.org/show_bug.cgi?id=100667
Summary [EFL][WK2] Avoid useless assignment in EwkViewImpl::setCustomTextEncodingName()
Chris Dumez
Reported 2012-10-29 06:25:14 PDT
We currently do the following in EwkViewImpl::setCustomTextEncodingName(encoding): m_customEncoding = encoding; m_pageProxy->setCustomTextEncodingName(encoding); Then, we assign again m_customEncoding in EwkViewImpl::customTextEncodingName(): String customEncoding = m_pageProxy->customTextEncodingName(); if (customEncoding.isEmpty()) return 0; m_customEncoding = customEncoding.utf8().data(); return m_customEncoding; The assignment in EwkViewImpl::setCustomTextEncodingName() is useless since the value is anyway set when calling EwkViewImpl::setCustomTextEncodingName(encoding). We can therefore get rid of it.
Attachments
Patch (3.15 KB, patch)
2012-10-29 06:28 PDT, Chris Dumez
no flags
Chris Dumez
Comment 1 2012-10-29 06:28:51 PDT
Mikhail Pozdnyakov
Comment 2 2012-10-29 06:37:56 PDT
Comment on attachment 171226 [details] Patch LGTM
Gyuyoung Kim
Comment 3 2012-10-29 06:56:49 PDT
Comment on attachment 171226 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=171226&action=review > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:817 > + impl->setCustomTextEncodingName(encoding ? encoding : String()); I think you need to use String::fromUTF8(encoding).
Chris Dumez
Comment 4 2012-10-29 07:02:12 PDT
(In reply to comment #3) > (From update of attachment 171226 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=171226&action=review > > > Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:817 > > + impl->setCustomTextEncodingName(encoding ? encoding : String()); > > I think you need to use String::fromUTF8(encoding). Can we really have non-ASCII characters in the encoding name? I don't think so.
WebKit Review Bot
Comment 5 2012-10-29 07:37:40 PDT
Comment on attachment 171226 [details] Patch Clearing flags on attachment: 171226 Committed r132800: <http://trac.webkit.org/changeset/132800>
WebKit Review Bot
Comment 6 2012-10-29 07:37:44 PDT
All reviewed patches have been landed. Closing bug.
Gyuyoung Kim
Comment 7 2012-10-29 08:54:41 PDT
Comment on attachment 171226 [details] Patch View in context: https://bugs.webkit.org/attachment.cgi?id=171226&action=review >>> Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:817 >>> + impl->setCustomTextEncodingName(encoding ? encoding : String()); >> >> I think you need to use String::fromUTF8(encoding). > > Can we really have non-ASCII characters in the encoding name? I don't think so. I think this is not related to set non-ASCII character as encoding name. This is to check if const char* is valid utf8 or not, and to convert from utf8() to utf16(). If we use encoding name without converting, encoding name might to be broken when it is converted to String implicitly. I think setCustomTextEncodingName(() will check if encoding character can be adjusted or not. GTK port also uses String::fromUTF8()
Chris Dumez
Comment 8 2012-10-29 10:00:33 PDT
(In reply to comment #7) > (From update of attachment 171226 [details]) > View in context: https://bugs.webkit.org/attachment.cgi?id=171226&action=review > > >>> Source/WebKit2/UIProcess/API/efl/ewk_view.cpp:817 > >>> + impl->setCustomTextEncodingName(encoding ? encoding : String()); > >> > >> I think you need to use String::fromUTF8(encoding). > > > > Can we really have non-ASCII characters in the encoding name? I don't think so. > > I think this is not related to set non-ASCII character as encoding name. This is to check if const char* is valid utf8 or not, and to convert from utf8() to utf16(). If we use encoding name without converting, encoding name might to be broken when it is converted to String implicitly. I think setCustomTextEncodingName(() will check if encoding character can be adjusted or not. GTK port also uses String::fromUTF8() If we don't call String::fromUTF8() then the input string is treated as ASCII. This is safe (and likely faster) as long as the input string only contains ASCII characters. Since I don't think it is valid to have non-ASCII characters in an encoding name, I think my code is correct.
Note You need to log in before you can comment on or make changes to this bug.