Hi all,<br><br><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote"><br></blockquote><blockquote style="margin:0pt 0pt 0pt 0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex" class="gmail_quote">
Surprising! That means that the runtime check is somehow erased by the<br>
compiler---cool. Probably a special optimization rule for the oh so<br>
common 'constructors with a boolean'. Ok---if it is like that then I<br>
have no concerns going for your suggestion.<br></blockquote><br>OK, I updated the code:<br> <a href="https://github.com/imagej/imglib/commit/5239120f">https://github.com/imagej/imglib/commit/5239120f</a><br><br>Feel free to revert it if these changes cause any problems.<br>
<br>Regards,<br>Curtis<br><br><br><div class="gmail_quote">On Thu, Mar 22, 2012 at 4:52 PM, Stephan Saalfeld <span dir="ltr"><<a href="mailto:saalfeld@mpi-cbg.de">saalfeld@mpi-cbg.de</a>></span> wrote:<br><blockquote class="gmail_quote" style="margin:0 0 0 .8ex;border-left:1px #ccc solid;padding-left:1ex">
Surprising! That means that the runtime check is somehow erased by the<br>
compiler---cool. Probably a special optimization rule for the oh so<br>
common 'constructors with a boolean'. Ok---if it is like that then I<br>
have no concerns going for your suggestion.<br>
<br>
Best,<br>
Stephan<br>
<div class="HOEnZb"><div class="h5"><br>
<br>
On Wed, 2012-03-21 at 13:25 -0500, Curtis Rueden wrote:<br>
> Hi Stephan,<br>
><br>
><br>
> I agree that your version is easier to understand and cleaner<br>
> to read<br>
> but it introduces a runtime check that although being tiny,<br>
> will slow<br>
> down the wrapping of Points and RealPoints slightly.<br>
><br>
> Thanks for the explanation. But I don't I buy it. Here is a little<br>
> test:<br>
><br>
> <a href="https://gist.github.com/2150639" target="_blank">https://gist.github.com/2150639</a><br>
><br>
> On my system:<br>
><br>
> Five trials of RealPointSS yields: 418, 361, 357, 359, 370<br>
> Five trials of RealPointCR yields: 365, 357, 357, 372, 360<br>
><br>
> With each trial consisting of 10 million object creations.<br>
><br>
> The difference looks negligible to me.<br>
><br>
> Regards,<br>
> Curtis<br>
><br>
><br>
> On Wed, Mar 21, 2012 at 3:48 AM, Stephan Saalfeld<br>
> <<a href="mailto:saalfeld@mpi-cbg.de">saalfeld@mpi-cbg.de</a>> wrote:<br>
> Hi Curtis,<br>
><br>
> since I am responsible for that construct, I take the freedom<br>
> to reply.<br>
><br>
> I agree that your version is easier to understand and cleaner<br>
> to read<br>
> but it introduces a runtime check that although being tiny,<br>
> will slow<br>
> down the wrapping of Points and RealPoints slightly. In<br>
> situations<br>
> where this is happening millions of times, I do not want the<br>
> additional<br>
> cost. So, I prefer your solution in business code but ImgLib2<br>
> aims to<br>
> be performance code :). For clarity, the constructor is<br>
> protected and<br>
> therefore not exposed to the normal API user, a clear Javadoc<br>
> should<br>
> tell extenders about its expected use. Normally, you will use<br>
> the<br>
> RealPoint.wrap(double[]) factory method instead. We could<br>
> make the<br>
> constructor private but then we would lose the option to use<br>
> it from the<br>
> now extending classes.<br>
><br>
> If this is still too ugly for your gusto, we could make the<br>
> current<br>
> RealPoint and Point AbstractRealPoint and AbstractPoint and<br>
> introduce<br>
> both this constructor and the static wrap method in the<br>
> extending<br>
> RealPoint and Point classes. I'd actually like that.<br>
><br>
> Best,<br>
> Stephan<br>
><br>
><br>
><br>
><br>
> On Tue, 2012-03-20 at 23:17 -0500, Curtis Rueden wrote:<br>
> > Hi Tobias,<br>
> ><br>
> > First of all, thanks very much for all the API improvements!<br>
> ><br>
> > I just have one comment...<br>
> ><br>
> > Why is there the Object x in there?<br>
> ><br>
> > If it wouldn't be there, then the compiler would be<br>
> unable to<br>
> > distinguish whether you call<br>
> > protected Realpoint( final double[] position )<br>
> > or<br>
> > public RealPoint( final double... position )<br>
> ><br>
> > Sure, the dummy Object parameter differentiates the<br>
> constructors.<br>
> > However, I do not believe such drastic measures are<br>
> necessary. Why not<br>
> > do something like this instead:<br>
> ><br>
> > <a href="https://gist.github.com/2144264" target="_blank">https://gist.github.com/2144264</a><br>
> ><br>
> > I think it is easier to understand and accomplishes the same<br>
> ends.<br>
> ><br>
> > Regards,<br>
> > Curtis<br></div></div></blockquote></div>