Use lambdas instead of std::bind()
ClosedPublic

Authored by volkov on Oct 16 2018, 2:11 PM.

Diff Detail

Repository
R127 KWayland
Branch
master
Lint
Lint OK
Unit
No Unit Test Coverage
Build Status
Buildable 3950
Build 3968: arc lint + arc unit
volkov created this revision.Oct 16 2018, 2:11 PM
Restricted Application added a project: Frameworks. · View Herald TranscriptOct 16 2018, 2:11 PM
Restricted Application added a subscriber: kde-frameworks-devel. · View Herald Transcript
volkov requested review of this revision.Oct 16 2018, 2:11 PM
volkov added a reviewer: KWin.Oct 16 2018, 2:13 PM
ivan added a subscriber: ivan.Oct 16 2018, 2:18 PM

The parentheses are not necessary when a lambda has no arguments.

[something]() { ::: }

can become:

[something] { ::: }

KWin uses both of these from what I've seen. Personally, I prefer the second.

Otherwise, +1 for the change.

Use lambdas instead of std::bind()

Why?

bruns added a subscriber: bruns.Oct 16 2018, 2:21 PM
In D16250#344183, @ivan wrote:

The parentheses are not necessary when a lambda has no arguments.

[something]() { ::: }

can become:

[something] { ::: }

KWin uses both of these from what I've seen. Personally, I prefer the second.

Otherwise, +1 for the change.

Qt coding style mandates the first

ivan added a comment.EditedOct 16 2018, 2:26 PM

@davidedmundson

Lambdas are generally faster to compile and execute. std::bind can make code less verbose, but that is not the case here (I'd say that lambdas win on succinctness here).

@bruns

Well... Qt has quite a few strange guidelines that we don't follow :) (p.s. I'm not against it going in with the parentheses, just making a note)

@davidedmundson

Lambdas are more readable.

https://clang.llvm.org/extra/clang-tidy/checks/modernize-avoid-bind.html

std::bind can be hard to read and can result in larger object files and binaries due to type information that will not be produced by equivalent lambdas.

davidedmundson accepted this revision.Nov 19 2018, 11:06 AM
This revision is now accepted and ready to land.Nov 19 2018, 11:06 AM
volkov closed this revision.Nov 19 2018, 11:47 AM