[cfe-dev] r253904 - Replace loop with std::any_of, NFC.

Yaron Keren via cfe-dev cfe-dev at lists.llvm.org
Tue Nov 24 12:22:02 PST 2015


OK, r254013.


2015-11-24 21:49 GMT+02:00 David Blaikie <dblaikie at gmail.com>:

>
>
> On Tue, Nov 24, 2015 at 11:39 AM, Yaron Keren <yaron.keren at gmail.com>
> wrote:
>
>> Hi,
>>
>> Should the [=] capture be replaced here with [&] ?
>>
>
> That would be my preference/notion - as I was saying on another review, I
> think it's probably best to default to [&] for any locally scoped lambda (I
> feel more sure about this for a lambda only used within the full expression
> where it is defined (ie: in standard algorithm usage), but even probably
> the right idea for a lambda declared in a lexical scope and only used there
> - not escaped via std::function or similar)
>
>
>> The original reasoning was it's more efficient to capture DeclModule by
>> value rather than by reference.
>>
>
> Yeah, I figured that was the likely logic - I'd be inclined to just rely
> on the optimizers to fix this where useful/necessary & keep a simpler rule
> of thumb for the usage.
>
>
>>
>> Yaron
>>
>>
>>
>> ---------- Forwarded message ----------
>> From: Yaron Keren via cfe-commits <cfe-commits at lists.llvm.org>
>> Date: 2015-11-23 21:28 GMT+02:00
>> Subject: r253904 - Replace loop with std::any_of, NFC.
>> To: ‫cfe-commits at lists.llvm.org>>
>> Author: yrnkrn
>> Date: Mon Nov 23 13:28:42 2015
>> New Revision: 253904
>>
>> URL: http://llvm.org/viewvc/llvm-project?rev=253904&view=rev
>> Log:
>> Replace loop with std::any_of, NFC.
>> Inspired by similar commits from Craig Topper.
>>
>>
>> Modified:
>>     cfe/trunk/lib/Sema/SemaLookup.cpp
>>
>> Modified: cfe/trunk/lib/Sema/SemaLookup.cpp
>> URL:
>> http://llvm.org/viewvc/llvm-project/cfe/trunk/lib/Sema/SemaLookup.cpp?rev=253904&r1=253903&r2=253904&view=diff
>>
>> ==============================================================================
>> --- cfe/trunk/lib/Sema/SemaLookup.cpp (original)
>> +++ cfe/trunk/lib/Sema/SemaLookup.cpp Mon Nov 23 13:28:42 2015
>> @@ -1535,12 +1535,8 @@ bool LookupResult::isVisibleSlow(Sema &S
>>
>>    // Check whether DeclModule is transitively exported to an import of
>>    // the lookup set.
>> -  for (llvm::DenseSet<Module *>::iterator I = LookupModules.begin(),
>> -                                          E = LookupModules.end();
>> -       I != E; ++I)
>> -    if ((*I)->isModuleVisible(DeclModule))
>> -      return true;
>> -  return false;
>> +  return std::any_of(LookupModules.begin(), LookupModules.end(),
>> +                     [=](Module *M) { return
>> M->isModuleVisible(DeclModule); });
>>  }
>>
>>  bool Sema::isVisibleSlow(const NamedDecl *D) {
>>
>>
>> _______________________________________________
>> cfe-commits mailing list
>> cfe-commits at lists.llvm.org
>> http://lists.llvm.org/cgi-bin/mailman/listinfo/cfe-commits
>>
>
>
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://lists.llvm.org/pipermail/cfe-dev/attachments/20151124/707ba58a/attachment.html>


More information about the cfe-dev mailing list