On 10/22/2012 01:41 AM, Galder ZamarreƱo wrote:
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);
No, that's inaccurate; they are singletons and do not use ID_NEW_OBJECT.
They're done as instances so it is one of:
public static final int ID_EMPTY_LIST_OBJECT = 0x5d;
public static final int ID_EMPTY_SET_OBJECT = 0x62;
public static final int ID_EMPTY_MAP_OBJECT = 0x69;
Your externalizers on the other hand take multiple bytes even in the
simplest case. If it is that important, you could use an ObjectResolver
to swap in the JDK instance instead of using yet another externalizer
(which has several bytes of overhead of its own).
--
- DML