On Oct 19, 2012, at 7:20 PM, David M. Lloyd <david.lloyd(a)redhat.com> wrote:
Also be aware that JBMAR has specific optimizations for the JDK empty
collections - they are represented by a single byte in the stream.
Well, it's actually 3 bytes that you use to represent empty collections (at least in
1.3.15ga):
write(ID_NEW_OBJECT);
write(ID_CLASS_CLASS);
write(classByte);
Whereas with our externalizers, these get resolved via object writer (which gets called
before your code to detect empty collections) and it only writes 1 byte:
write(externalizerId);
Cheers,
On 10/19/2012 11:28 AM, Dan Berindei wrote:
> Galder, what JDK are you using? OpenJDK 1.7 uses
> EmptyIterator.EMPTY_ITERATOR since 2007:
>
>
http://hg.openjdk.java.net/jdk7/jdk7/jdk/annotate/37a05a11f281/src/share/...
>
> I don't have JDK 1.6 sources on hand to check, but I don't think it's
> worth optimizing for such an old version anyway.
>
> Cheers
> Dan
>
>
> On Fri, Oct 19, 2012 at 5:50 PM, Vladimir Blagojevic
> <vblagoje(a)redhat.com <mailto:vblagoje@redhat.com>> wrote:
>
> Cool! Did not know about this! Is this original idea or others are
> already doing this?
> On 12-10-19 8:31 AM, Galder Zamarreño wrote:
>> Hi all,
>>
>> Re:
>
https://github.com/galderz/infinispan/commit/0609207d13216de81d77ff51dc20...
>>
>> Please avoid using these JDK methods where possible. I've created
> alternative versions in InfinispanCollections util class that
> provide a better implementation.
>>
>> The problem with the JDK versions is that even if these
> collections are immutable, if you wanna iterate them (i.e. for(X :
> emptySet) ), they'll create a brand new Iterator every time they're
> looped, and that generates useless garbage.
>>
>> The InfinispanCollections versions of emptyX will return a
> constant singleton iterator which avoids this problem, and avoids
> the need for client code to check if the collection is empty before
> looping.
>>
>> Cheers,
>> --
>> Galder Zamarreño
>> galder(a)redhat.com <mailto:galder@redhat.com>
>>
twitter.com/galderz <
http://twitter.com/galderz>
>>
>> Project Lead, Escalante
>>
http://escalante.io
>>
>> Engineer, Infinispan
>>
http://infinispan.org
>>
>>
>> _______________________________________________
>> infinispan-dev mailing list
>> infinispan-dev(a)lists.jboss.org
> <mailto:infinispan-dev@lists.jboss.org>
>>
https://lists.jboss.org/mailman/listinfo/infinispan-dev
>
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev(a)lists.jboss.org <mailto:infinispan-dev@lists.jboss.org>
>
https://lists.jboss.org/mailman/listinfo/infinispan-dev
>
>
>
>
> _______________________________________________
> infinispan-dev mailing list
> infinispan-dev(a)lists.jboss.org
>
https://lists.jboss.org/mailman/listinfo/infinispan-dev
>
--
- DML
_______________________________________________
infinispan-dev mailing list
infinispan-dev(a)lists.jboss.org
https://lists.jboss.org/mailman/listinfo/infinispan-dev