Title: [152832] trunk/Source/WebCore
Revision
152832
Author
[email protected]
Date
2013-07-18 00:27:16 -0700 (Thu, 18 Jul 2013)

Log Message

[gstreamer] Avoid calls to g_slist_index in webKitWebAudioSrcLoop()
https://bugs.webkit.org/show_bug.cgi?id=118827

Patch by Nick Diego Yamane <[email protected]> on 2013-07-18
Reviewed by Philippe Normand.

webKitWebAudioSrcLoop() currently calls g_slist_index for each element
to get its index in a list it's iterating over. g_list_index function uses
a sequential search to find that element, which is clearly unecessary.
This patch adds a local variable to store the current index and use it
instead of calling g_slist_index function.

No new tests, no behavior changes.

* platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
(webKitWebAudioSrcLoop):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (152831 => 152832)


--- trunk/Source/WebCore/ChangeLog	2013-07-18 07:27:08 UTC (rev 152831)
+++ trunk/Source/WebCore/ChangeLog	2013-07-18 07:27:16 UTC (rev 152832)
@@ -1,3 +1,21 @@
+2013-07-18  Nick Diego Yamane  <[email protected]>
+
+        [gstreamer] Avoid calls to g_slist_index in webKitWebAudioSrcLoop()
+        https://bugs.webkit.org/show_bug.cgi?id=118827
+
+        Reviewed by Philippe Normand.
+
+        webKitWebAudioSrcLoop() currently calls g_slist_index for each element 
+        to get its index in a list it's iterating over. g_list_index function uses
+        a sequential search to find that element, which is clearly unecessary.
+        This patch adds a local variable to store the current index and use it 
+        instead of calling g_slist_index function.
+
+        No new tests, no behavior changes.
+
+        * platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp:
+        (webKitWebAudioSrcLoop):
+
 2013-07-17  Gyuyoung Kim  <[email protected]>
 
         Introduce toSVGInlineFlowBox() and use it

Modified: trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp (152831 => 152832)


--- trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp	2013-07-18 07:27:08 UTC (rev 152831)
+++ trunk/Source/WebCore/platform/audio/gstreamer/WebKitWebAudioSourceGStreamer.cpp	2013-07-18 07:27:16 UTC (rev 152832)
@@ -354,8 +354,9 @@
         return;
 
     GSList* channelBufferList = 0;
+    register int i;
     unsigned bufferSize = priv->framesToPull * sizeof(float);
-    for (int i = g_slist_length(priv->pads) - 1; i >= 0; i--) {
+    for (i = g_slist_length(priv->pads) - 1; i >= 0; i--) {
         GstBuffer* channelBuffer = gst_buffer_new_and_alloc(bufferSize);
         ASSERT(channelBuffer);
         channelBufferList = g_slist_prepend(channelBufferList, channelBuffer);
@@ -372,16 +373,16 @@
     // FIXME: Add support for local/live audio input.
     priv->provider->render(0, priv->bus, priv->framesToPull);
 
-    GSList* padsIt;
-    GSList* buffersIt;
-    for (padsIt = priv->pads, buffersIt = channelBufferList; padsIt && buffersIt; padsIt = g_slist_next(padsIt), buffersIt = g_slist_next(buffersIt)) {
+    GSList* padsIt = priv->pads;
+    GSList* buffersIt = channelBufferList;
+    for (i = 0; padsIt && buffersIt; padsIt = g_slist_next(padsIt), buffersIt = g_slist_next(buffersIt), ++i) {
         GstPad* pad = static_cast<GstPad*>(padsIt->data);
         GstBuffer* channelBuffer = static_cast<GstBuffer*>(buffersIt->data);
 
 #ifndef GST_API_VERSION_1
         GRefPtr<GstCaps> monoCaps = adoptGRef(getGStreamerMonoAudioCaps(priv->sampleRate));
         GstStructure* structure = gst_caps_get_structure(monoCaps.get(), 0);
-        GstAudioChannelPosition channelPosition = webKitWebAudioGStreamerChannelPosition(g_slist_index(channelBufferList, channelBuffer));
+        GstAudioChannelPosition channelPosition = webKitWebAudioGStreamerChannelPosition(i);
         gst_audio_set_channel_positions(structure, &channelPosition);
         gst_buffer_set_caps(channelBuffer, monoCaps.get());
 #endif
_______________________________________________
webkit-changes mailing list
[email protected]
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to