From 09ff91cbdb635c6422a1a69aed5b5c9892b026e3 Mon Sep 17 00:00:00 2001 From: "Ray J. Greenwell" Date: Wed, 20 Mar 2013 18:02:09 -0700 Subject: [PATCH] Let's just reflect once when there's no 0-arg constructor. --- core/src/main/java/com/threerings/io/Streamer.java | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/core/src/main/java/com/threerings/io/Streamer.java b/core/src/main/java/com/threerings/io/Streamer.java index a9bd6015c..e10e8be6c 100644 --- a/core/src/main/java/com/threerings/io/Streamer.java +++ b/core/src/main/java/com/threerings/io/Streamer.java @@ -413,7 +413,8 @@ public abstract class Streamer protected void initConstructor () { // if we have a zero argument constructor, we have to use that one - for (Constructor ctor : _target.getDeclaredConstructors()) { + Constructor[] ctors = _target.getDeclaredConstructors(); + for (Constructor ctor : ctors) { if (ctor.getParameterTypes().length == 0) { _ctor = ctor; _ctorArgs = ArrayUtil.EMPTY_OBJECT; @@ -424,7 +425,6 @@ public abstract class Streamer // otherwise there should be a single non-zero-argument constructor, which we'll call // with zero-valued arguments at unstreaming time, which will then be overwritten by // readObject() - Constructor[] ctors = _target.getDeclaredConstructors(); if (ctors.length > 1) { throw new RuntimeException( "Streamable closure classes must have either a zero-argument constructor " +