Index: webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc |
diff --git a/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc b/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc |
index b17c195340b0e495fa6e123a2b33c06141e9a2c5..2256e162fb4aa94be2052402f93744b8c396e6f0 100644 |
--- a/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc |
+++ b/webrtc/modules/desktop_capture/win/dxgi_output_duplicator.cc |
@@ -285,9 +285,9 @@ void DxgiOutputDuplicator::Setup(Context* context) { |
} |
void DxgiOutputDuplicator::Unregister(const Context* const context) { |
- for (size_t i = 0; i < contexts_.size(); i++) { |
- if (contexts_[i] == context) { |
- contexts_[i] = nullptr; |
+ for (auto it = contexts_.begin(); it != contexts_.end(); it++) { |
Sergey Ulanov
2016/11/11 18:27:18
This loop can be replaced with std::find:
contex
Hzj_jie
2016/11/11 21:51:31
Done.
|
+ if (*it == context) { |
+ contexts_.erase(it); |
Sergey Ulanov
2016/11/11 18:27:18
What was the reason this code was implemented this
Hzj_jie
2016/11/11 21:51:31
Because std::vector::erase is O(n) instead of O(1)
Sergey Ulanov
2016/11/11 22:57:35
FWIW it can be O(1) if you swap it with the last e
Hzj_jie
2016/11/11 23:28:22
Oh, yes, since we have searched already. But the n
|
return; |
} |
} |
@@ -297,6 +297,7 @@ void DxgiOutputDuplicator::Unregister(const Context* const context) { |
void DxgiOutputDuplicator::SpreadContextChange(const Context* const source) { |
for (Context* dest : contexts_) { |
+ RTC_DCHECK(dest); |
if (dest != source) { |
dest->updated_region.AddRegion(source->updated_region); |
} |