I think for a small instance like this (two object references already
allocated) it will actually be much faster creating them each time rather
than the invocations and setup to do pooling. I've benchmarked this before
and for small object its a pretty fast pop. Only because the kryo instance
and/or output could change and that would need to be checked for. Plus it
adds complexity with dubious benefit. But I will mos def do it if you feel
strongly about it.


On Tue, Jan 7, 2014 at 2:34 PM, Nathan Sweet <notifications@github.com>wrote:

> In src/com/esotericsoftware/kryo/serializers/ExternalizableSerializer.java:
>
> > +        this.checkForReplaceMethods = checkForReplaceMethods;
> > +    }
> > +
> > +    @Override
> > +    public void write( Kryo kryo, Output output, Object object ) {
> > +        JavaSerializer serializer = getJavaSerializer( object.getClass() );
> > +        if ( serializer == null ) {
> > +            writeExternal( kryo, output, (Externalizable)object );
> > +        }
> > +        else {
> > +            serializer.write( kryo, output, object );
> > +        }
> > +    }
> > +
> > +    protected void writeExternal( Kryo kryo, Output output, Externalizable object ) {
> > +        ObjectOutput objectOutput = new KryoObjectOutput( kryo, output );
>
> Would be nice to avoid allocation when it is easy enough. KryoObjectOutput
> could allow the Kryo instance to be changed.
>
> —
> Reply to this email directly or view it on GitHub<https://github.com/EsotericSoftware/kryo/pull/167/files#r8709688>
> .
>