Title: [221562] trunk/Source
- Revision
- 221562
- Author
- [email protected]
- Date
- 2017-09-03 18:38:09 -0700 (Sun, 03 Sep 2017)
Log Message
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: trunk/Source/WebCore/ChangeLog (221561 => 221562)
--- trunk/Source/WebCore/ChangeLog 2017-09-04 01:37:05 UTC (rev 221561)
+++ trunk/Source/WebCore/ChangeLog 2017-09-04 01:38:09 UTC (rev 221562)
@@ -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: trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp (221561 => 221562)
--- trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2017-09-04 01:37:05 UTC (rev 221561)
+++ trunk/Source/WebCore/Modules/websockets/WebSocketChannel.cpp 2017-09-04 01:38:09 UTC (rev 221562)
@@ -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: trunk/Source/WebCore/platform/wpe/PlatformPasteboardWPE.cpp (221561 => 221562)
--- trunk/Source/WebCore/platform/wpe/PlatformPasteboardWPE.cpp 2017-09-04 01:37:05 UTC (rev 221561)
+++ trunk/Source/WebCore/platform/wpe/PlatformPasteboardWPE.cpp 2017-09-04 01:38:09 UTC (rev 221562)
@@ -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: trunk/Source/WebKit/ChangeLog (221561 => 221562)
--- trunk/Source/WebKit/ChangeLog 2017-09-04 01:37:05 UTC (rev 221561)
+++ trunk/Source/WebKit/ChangeLog 2017-09-04 01:38:09 UTC (rev 221562)
@@ -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-03 Tim Horton <[email protected]>
Move shared part of the Remote Layer Tree code out of a Mac-specific directory
Modified: trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.cpp (221561 => 221562)
--- trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.cpp 2017-09-04 01:37:05 UTC (rev 221561)
+++ trunk/Source/WebKit/NetworkProcess/webrtc/NetworkRTCSocket.cpp 2017-09-04 01:38:09 UTC (rev 221562)
@@ -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