Title: [221581] releases/WebKitGTK/webkit-2.18/Source
Revision
221581
Author
[email protected]
Date
2017-09-04 02:22:13 -0700 (Mon, 04 Sep 2017)

Log Message

Merge r221562 - String#utf8() allocates new CString
https://bugs.webkit.org/show_bug.cgi?id=176302

Reviewed by Sam Weinig.

Source/WebCore:

Several places uses String#utf8() like an accessor. In reality, it allocates new CString per call.
It is very costly. Furthermore, some places uses this incorrectly. For example,
`std::vector<char>(srtpAuth.utf8().data(), srtpAuth.utf8().data() + srtpAuth.utf8().length());`
is incorrect since each time strpAuth.utf8() allocates different CString.

This patch calls utf8() first and use it.

* Modules/websockets/WebSocketChannel.cpp:
(WebCore::WebSocketChannel::startClosingHandshake):
* platform/wpe/PlatformPasteboardWPE.cpp:
(WebCore::PlatformPasteboard::write):

Source/WebKit:

* NetworkProcess/webrtc/NetworkRTCSocket.cpp:
(WebKit::NetworkRTCSocket::sendTo):

Modified Paths

Diff

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog (221580 => 221581)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog	2017-09-04 09:22:05 UTC (rev 221580)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/ChangeLog	2017-09-04 09:22:13 UTC (rev 221581)
@@ -1,5 +1,24 @@
 2017-09-03  Yusuke Suzuki  <[email protected]>
 
+        String#utf8() allocates new CString
+        https://bugs.webkit.org/show_bug.cgi?id=176302
+
+        Reviewed by Sam Weinig.
+
+        Several places uses String#utf8() like an accessor. In reality, it allocates new CString per call.
+        It is very costly. Furthermore, some places uses this incorrectly. For example,
+        `std::vector<char>(srtpAuth.utf8().data(), srtpAuth.utf8().data() + srtpAuth.utf8().length());`
+        is incorrect since each time strpAuth.utf8() allocates different CString.
+
+        This patch calls utf8() first and use it.
+
+        * Modules/websockets/WebSocketChannel.cpp:
+        (WebCore::WebSocketChannel::startClosingHandshake):
+        * platform/wpe/PlatformPasteboardWPE.cpp:
+        (WebCore::PlatformPasteboard::write):
+
+2017-09-03  Yusuke Suzuki  <[email protected]>
+
         [SOUP] Use fastMalloced SoupBuffer in ResourcehandleSoup
         https://bugs.webkit.org/show_bug.cgi?id=176311
 

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (221580 => 221581)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/Modules/websockets/WebSocketChannel.cpp	2017-09-04 09:22:05 UTC (rev 221580)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/Modules/websockets/WebSocketChannel.cpp	2017-09-04 09:22:13 UTC (rev 221581)
@@ -492,7 +492,8 @@
         unsigned char lowByte = code;
         buf.append(static_cast<char>(highByte));
         buf.append(static_cast<char>(lowByte));
-        buf.append(reason.utf8().data(), reason.utf8().length());
+        auto reasonUTF8 = reason.utf8();
+        buf.append(reasonUTF8.data(), reasonUTF8.length());
     }
     enqueueRawFrame(WebSocketFrame::OpCodeClose, buf.data(), buf.size());
     Ref<WebSocketChannel> protectedThis(*this); // An attempt to send closing handshake may fail, which will get the channel closed and dereferenced.

Modified: releases/WebKitGTK/webkit-2.18/Source/WebCore/platform/wpe/PlatformPasteboardWPE.cpp (221580 => 221581)


--- releases/WebKitGTK/webkit-2.18/Source/WebCore/platform/wpe/PlatformPasteboardWPE.cpp	2017-09-04 09:22:05 UTC (rev 221580)
+++ releases/WebKitGTK/webkit-2.18/Source/WebCore/platform/wpe/PlatformPasteboardWPE.cpp	2017-09-04 09:22:13 UTC (rev 221581)
@@ -103,8 +103,11 @@
     struct wpe_pasteboard_string_pair pairs[] = {
         { { nullptr, 0 }, { nullptr, 0 } },
     };
-    wpe_pasteboard_string_initialize(&pairs[0].type, type.utf8().data(), type.utf8().length());
-    wpe_pasteboard_string_initialize(&pairs[0].string, string.utf8().data(), string.utf8().length());
+
+    auto typeUTF8 = type.utf8();
+    auto stringUTF8 = string.utf8();
+    wpe_pasteboard_string_initialize(&pairs[0].type, typeUTF8.data(), typeUTF8.length());
+    wpe_pasteboard_string_initialize(&pairs[0].string, stringUTF8.data(), stringUTF8.length());
     struct wpe_pasteboard_string_map map = { pairs, 1 };
 
     wpe_pasteboard_write(m_pasteboard, &map);

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKit/ChangeLog (221580 => 221581)


--- releases/WebKitGTK/webkit-2.18/Source/WebKit/ChangeLog	2017-09-04 09:22:05 UTC (rev 221580)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKit/ChangeLog	2017-09-04 09:22:13 UTC (rev 221581)
@@ -1,3 +1,13 @@
+2017-09-03  Yusuke Suzuki  <[email protected]>
+
+        String#utf8() allocates new CString
+        https://bugs.webkit.org/show_bug.cgi?id=176302
+
+        Reviewed by Sam Weinig.
+
+        * NetworkProcess/webrtc/NetworkRTCSocket.cpp:
+        (WebKit::NetworkRTCSocket::sendTo):
+
 2017-09-02  Carlos Garcia Campos  <[email protected]>
 
         [GTK][Wayland] Use fast malloc to allocate backing store cairo surfaces data

Modified: releases/WebKitGTK/webkit-2.18/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.cpp (221580 => 221581)


--- releases/WebKitGTK/webkit-2.18/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.cpp	2017-09-04 09:22:05 UTC (rev 221580)
+++ releases/WebKitGTK/webkit-2.18/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.cpp	2017-09-04 09:22:13 UTC (rev 221581)
@@ -51,9 +51,10 @@
     options.packet_time_params.rtp_sendtime_extension_id = rtpSendtimeExtensionID;
     options.packet_time_params.srtp_packet_index = srtpPacketIndex;
     options.dscp = static_cast<rtc::DiffServCodePoint>(dscp);
-    if (srtpAuth.utf8().length()) {
-        options.packet_time_params.srtp_auth_key = std::vector<char>(srtpAuth.utf8().data(), srtpAuth.utf8().data() + srtpAuth.utf8().length());
-        options.packet_time_params.srtp_auth_tag_len = srtpAuth.utf8().length();
+    auto srtpAuthUTF8 = srtpAuth.utf8();
+    if (srtpAuthUTF8.length()) {
+        options.packet_time_params.srtp_auth_key = std::vector<char>(srtpAuthUTF8.data(), srtpAuthUTF8.data() + srtpAuthUTF8.length());
+        options.packet_time_params.srtp_auth_tag_len = srtpAuthUTF8.length();
     } else
         options.packet_time_params.srtp_auth_tag_len = -1;
     
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to