Predicates?
Remi Forax
forax at univ-mlv.fr
Thu Apr 18 13:59:20 PDT 2013
On 04/18/2013 09:16 PM, Brian Goetz wrote:
>> Predicate<String> isNull = Objects::isNull;
>>
>> On performance: I'm sure Guava is optimized so that its methods
>> always return a singleton. In principle, the semantics of lambdas
>> and method references are abstract enough that you shouldn't have to
>> worry about that. In practice, I wouldn't expect clever
>> optimizations like that (e.g., turning every "x -> true" into the
>> same object) in the near future.
> TO be clear: with our implementation, every invocation of the *statement*
>
> Predicate<String> p = () -> true;
>
> always does return the same object. What Dan is talking about is
> something different; if two places in the code have "equivalent"
> lambdas, whether they would be "interned".
>
>
Interning object is premature optimization, anyway.
The VM has trouble to remove allocation of interned objects.
Rémi
More information about the lambda-dev
mailing list