Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(530)

Issue 3005433002: Fix places that trigger no-unused-lambda-capture (Closed)

Created:
3 years, 4 months ago by eladalon
Modified:
3 years, 4 months ago
CC:
webrtc-reviews_webrtc.org, video-team_agora.io, AleBzk, peah-webrtc, Andrew MacDonald, aleloi, tterriberry_mozilla.com, audio-team_agora.io, hlundin-webrtc, mflodman, kwiberg-webrtc, minyue-webrtc, the sun, yujie_mao (webrtc), zhengzhonghou_agora.io, aluebs-webrtc, bjornv1, kjellander_webrtc
Target Ref:
refs/heads/master
Project:
webrtc
Visibility:
Public.

Description

Fix places that trigger no-unused-lambda-capture no-unused-lambda-capture was suppressed, but it's been decided as desireable to stop suppressing it. This CL fixes places in the code that trigger it. 1. Some unnecessary captures removed. 2. s/constexpr/const when capturing a float by value - this is good enough to stop the error. 3. Complete removal of the constexpr/const-modifier for int-types as a workaround. BUG=webrtc:7133 Review-Url: https://codereview.webrtc.org/3005433002 Cr-Commit-Position: refs/heads/master@{#19462} Committed: https://chromium.googlesource.com/external/webrtc/+/1cc5fc3ebfacefe8326abb6c3367be6ddf524957

Patch Set 1 #

Total comments: 6

Patch Set 2 : Rebased #

Total comments: 12
Unified diffs Side-by-side diffs Delta from patch set Stats (+31 lines, -23 lines) Patch
M webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc View 1 chunk +1 line, -1 line 6 comments Download
M webrtc/modules/audio_processing/aec3/adaptive_fir_filter_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M webrtc/modules/audio_processing/aec3/residual_echo_estimator.cc View 1 chunk +1 line, -1 line 0 comments Download
M webrtc/pc/channel_unittest.cc View 2 chunks +8 lines, -4 lines 4 comments Download
M webrtc/pc/rtcstatscollector_unittest.cc View 8 chunks +11 lines, -11 lines 0 comments Download
M webrtc/pc/webrtcsession_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download
M webrtc/video/end_to_end_tests.cc View 1 1 chunk +7 lines, -3 lines 2 comments Download
M webrtc/video/overuse_frame_detector_unittest.cc View 1 chunk +1 line, -1 line 0 comments Download

Messages

Total messages: 21 (7 generated)
eladalon
PTAL
3 years, 4 months ago (2017-08-23 09:33:38 UTC) #3
stefan-webrtc
https://codereview.webrtc.org/3005433002/diff/1/webrtc/pc/channel_unittest.cc File webrtc/pc/channel_unittest.cc (right): https://codereview.webrtc.org/3005433002/diff/1/webrtc/pc/channel_unittest.cc#newcode1214 webrtc/pc/channel_unittest.cc:1214: int kLastPacketId = 100; Can't we at least make ...
3 years, 4 months ago (2017-08-23 09:37:25 UTC) #4
nisse-webrtc
https://codereview.webrtc.org/3005433002/diff/1/webrtc/video/end_to_end_tests.cc File webrtc/video/end_to_end_tests.cc (right): https://codereview.webrtc.org/3005433002/diff/1/webrtc/video/end_to_end_tests.cc#newcode4273 webrtc/video/end_to_end_tests.cc:4273: // require them to be captured in the lambda, ...
3 years, 4 months ago (2017-08-23 09:42:03 UTC) #5
charujain1
On 2017/08/23 09:42:03, nisse-webrtc wrote: > https://codereview.webrtc.org/3005433002/diff/1/webrtc/video/end_to_end_tests.cc > File webrtc/video/end_to_end_tests.cc (right): > > https://codereview.webrtc.org/3005433002/diff/1/webrtc/video/end_to_end_tests.cc#newcode4273 > ...
3 years, 4 months ago (2017-08-23 09:57:06 UTC) #6
eladalon
Charu, I suggest I check in combination with Henrik's CL locally, but land my CL ...
3 years, 4 months ago (2017-08-23 10:26:26 UTC) #7
nisse-webrtc
lgtm
3 years, 4 months ago (2017-08-23 10:28:39 UTC) #8
kjellander_webrtc
lgtm I can do a try with my https://codereview.webrtc.org/2999403002/ after this lands. I think you ...
3 years, 4 months ago (2017-08-23 10:32:08 UTC) #10
stefan-webrtc
lgtm
3 years, 4 months ago (2017-08-23 10:42:14 UTC) #11
commit-bot: I haz the power
CQ is trying da patch. Follow status at: https://chromium-cq-status.appspot.com/v2/patch-status/codereview.webrtc.org/3005433002/20001
3 years, 4 months ago (2017-08-23 10:45:45 UTC) #13
commit-bot: I haz the power
Committed patchset #2 (id:20001) as https://chromium.googlesource.com/external/webrtc/+/1cc5fc3ebfacefe8326abb6c3367be6ddf524957
3 years, 4 months ago (2017-08-23 11:15:32 UTC) #16
kwiberg-webrtc
Sorry, it seems I was too slow (had to pause reviewing to have a meeting). ...
3 years, 4 months ago (2017-08-23 11:36:00 UTC) #18
eladalon
https://codereview.webrtc.org/3005433002/diff/20001/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc File webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc (right): https://codereview.webrtc.org/3005433002/diff/20001/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc#newcode510 webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc:510: const float kScale = 1.0f / kFftLengthBy2; On 2017/08/23 ...
3 years, 4 months ago (2017-08-23 11:42:53 UTC) #19
kwiberg-webrtc
https://codereview.webrtc.org/3005433002/diff/20001/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc File webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc (right): https://codereview.webrtc.org/3005433002/diff/20001/webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc#newcode512 webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc:512: [kScale](float& a) { a *= kScale; }); On 2017/08/23 ...
3 years, 4 months ago (2017-08-23 11:56:40 UTC) #20
eladalon
3 years, 4 months ago (2017-08-23 12:17:30 UTC) #21
Message was sent while issue was closed.
https://codereview.webrtc.org/3005433002/diff/20001/webrtc/modules/audio_proc...
File webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc (right):

https://codereview.webrtc.org/3005433002/diff/20001/webrtc/modules/audio_proc...
webrtc/modules/audio_processing/aec3/adaptive_fir_filter.cc:512: [kScale](float&
a) { a *= kScale; });
On 2017/08/23 11:56:40, kwiberg-webrtc wrote:
> On 2017/08/23 11:42:53, eladalon wrote:
> > On 2017/08/23 11:35:59, kwiberg-webrtc wrote:
> > > Does it work if you change the capture list to [&] instead? That's allowed
> > since
> > > the lambda doesn't outlive the scope in which it is created.
> > 
> > You can't capture a constexpr by reference, can you?
> 
> Yes, you can. Unlike preprocessor constants and enum values, they are lvalues,
> so you can take their address etc.

Surprising, but OK. Nevertheless, I am not sure that would be an improvement of
the code. I think it would be better with const than with an unlimited capture.
Unless you feel strongly about this, I'd rather not make that change.

https://codereview.webrtc.org/3005433002/diff/20001/webrtc/pc/channel_unittes...
File webrtc/pc/channel_unittest.cc (right):

https://codereview.webrtc.org/3005433002/diff/20001/webrtc/pc/channel_unittes...
webrtc/pc/channel_unittest.cc:1214: int kLastPacketId = 100;
On 2017/08/23 11:56:40, kwiberg-webrtc wrote:
> On 2017/08/23 11:42:53, eladalon wrote:
> > On 2017/08/23 11:35:59, kwiberg-webrtc wrote:
> > > Shouldn't they at least be const?
> > 
> > No, it doesn't work if they are. Please see my answer to Stefan about this.
> 
> Ugh. This is really bad.
> 
> What if we make them enums, and don't mention them in the capture list:
> 
>   enum : uint16_t { kLocalNetId = 1 };
>   enum : uint16_t { kRemoteNetId = 2 };
>   enum : int { kLastPacketId = 100 };
>   ...
>   network_thread_->Invoke<void>(RTC_FROM_HERE, [this] { ... });

Interesting suggestion. I'm trying out another suggestion from Tommi. If that
one doesn't work, I'll explore this instead.

Powered by Google App Engine
This is Rietveld 408576698