[PATCH] D119136: [clang] Implement Change scope of lambda trailing-return-type

Aaron Ballman via Phabricator via cfe-commits cfe-commits at lists.llvm.org
Wed Apr 13 10:07:23 PDT 2022


aaron.ballman added inline comments.


================
Comment at: clang/lib/Sema/SemaLambda.cpp:1127-1132
+      auto it = LSI->DelayedCaptures.end();
+      if (Var)
+        it = llvm::find_if(LSI->DelayedCaptures, [&Var](auto &&Pair) {
+          return Pair.second.Var == Var;
+        });
+      if (it != LSI->DelayedCaptures.end()) {
----------------
cor3ntin wrote:
> cor3ntin wrote:
> > aaron.ballman wrote:
> > > ChuanqiXu wrote:
> > > > I feel like my suggested change is simpler.
> > > +1 to this suggestion being a bit easier to read.
> > With that changes, a capture that is not in the delayed capture list forces us to go through the list of capture anyway, which seems like a waste.
> > So this is not just about readability. it should still work,  and only really matter for error cases, but it's still not identical code.
> Alternatively, I guess I can change the order of operation to ensure Var is never null here, and that would probably be cleaner!
Ah, thank you for pointing out that this was also about performance. If you're able to clean it up by changing the order of operations, that'd be good, but if it turns into a slog, I don't insist.


Repository:
  rG LLVM Github Monorepo

CHANGES SINCE LAST ACTION
  https://reviews.llvm.org/D119136/new/

https://reviews.llvm.org/D119136



More information about the cfe-commits mailing list