Title: [273894] trunk/Source/WebCore
Revision
273894
Author
you...@apple.com
Date
2021-03-04 09:49:24 -0800 (Thu, 04 Mar 2021)

Log Message

AVAudioSessionCaptureDeviceManager::retrieveAudioSessionCaptureDevices is unnecessarily creating a NSArray twice
https://bugs.webkit.org/show_bug.cgi?id=222732

Reviewed by Eric Carlson.

Before the patch, [m_audioSession availableInputs] was called twice.
This creates two NSArray which is not create from a memory standpoint.
There is also the risk that the two NSArrays have two different size, in which case Vector::uncheckedAppend would fail.

Cannot be easily tested, no observable change expected.

* platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm:
(WebCore::AVAudioSessionCaptureDeviceManager::retrieveAudioSessionCaptureDevices const):

Modified Paths

Diff

Modified: trunk/Source/WebCore/ChangeLog (273893 => 273894)


--- trunk/Source/WebCore/ChangeLog	2021-03-04 17:49:03 UTC (rev 273893)
+++ trunk/Source/WebCore/ChangeLog	2021-03-04 17:49:24 UTC (rev 273894)
@@ -1,5 +1,21 @@
 2021-03-04  Youenn Fablet  <you...@apple.com>
 
+        AVAudioSessionCaptureDeviceManager::retrieveAudioSessionCaptureDevices is unnecessarily creating a NSArray twice
+        https://bugs.webkit.org/show_bug.cgi?id=222732
+
+        Reviewed by Eric Carlson.
+
+        Before the patch, [m_audioSession availableInputs] was called twice.
+        This creates two NSArray which is not create from a memory standpoint.
+        There is also the risk that the two NSArrays have two different size, in which case Vector::uncheckedAppend would fail.
+
+        Cannot be easily tested, no observable change expected.
+
+        * platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm:
+        (WebCore::AVAudioSessionCaptureDeviceManager::retrieveAudioSessionCaptureDevices const):
+
+2021-03-04  Youenn Fablet  <you...@apple.com>
+
         Update camera and microphone capture state control WKWebView API
         https://bugs.webkit.org/show_bug.cgi?id=222166
 

Modified: trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm (273893 => 273894)


--- trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm	2021-03-04 17:49:03 UTC (rev 273893)
+++ trunk/Source/WebCore/platform/mediastream/ios/AVAudioSessionCaptureDeviceManager.mm	2021-03-04 17:49:24 UTC (rev 273894)
@@ -201,11 +201,12 @@
 
 Vector<AVAudioSessionCaptureDevice> AVAudioSessionCaptureDeviceManager::retrieveAudioSessionCaptureDevices() const
 {
-    Vector<AVAudioSessionCaptureDevice> newAudioDevices;
     auto *defaultInput = [m_audioSession currentRoute].inputs.firstObject;
-    newAudioDevices.reserveInitialCapacity([m_audioSession availableInputs].count);
+    auto availableInputs = [m_audioSession availableInputs];
 
-    for (AVAudioSessionPortDescription *portDescription in [m_audioSession availableInputs])
+    Vector<AVAudioSessionCaptureDevice> newAudioDevices;
+    newAudioDevices.reserveInitialCapacity(availableInputs.count);
+    for (AVAudioSessionPortDescription *portDescription in availableInputs)
         newAudioDevices.uncheckedAppend(AVAudioSessionCaptureDevice::create(portDescription, defaultInput));
 
     return newAudioDevices;
_______________________________________________
webkit-changes mailing list
webkit-changes@lists.webkit.org
https://lists.webkit.org/mailman/listinfo/webkit-changes

Reply via email to