> On Sat, Dec 31, 2011 at 6:16 AM, guast <
v.gu...-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org> wrote:
> > Hi All
>
> > I have a method that returns a tuple of (Int, Double, Double). I am
> > returning some fields of the same type. However in the generated class
> > I can see that the value are boxed. That method will be called
> > millions of times so I am trying to optimize it as much as possible,
> > but I can't avoid the boxing. Is there a way to do it ?
>
> > This is the last version of the method:
>
> > private def getIterations(x:Double, y:Double, x_0:Double,
> > y_0:Double, iterations: Int):(Int, Double,
> > Double) = {
> > if (iterations < maxIterations && x*x + y*y <= 4)
> > getIterations(x*x - y*y + x_0, x*y*2.0 + y_0, x_0, y_0,
> > iterations+1)
> > else (iterations, x, y)
> > }
>
> > This is the generated code:
> > final def mandelbrotsetdesigner$FunctionIterator$$getIterations(x:
> > Double, y: Double, x_0: Double, y_0: Double, iterations: Int): Tuple3
> > = {
> > <synthetic> val _$this: mandelbrotsetdesigner.FunctionIterator =
> > FunctionIterator.this;
> > _getIterations(_$this,x,y,x_0,y_0,iterations){
> > if (iterations.<(FunctionIterator.this.maxIterations()).&&(x.*(x).+
> > (y.*(y)).<=(4)))
> > _getIterations(FunctionIterator.this, x.*(x).-(y.*(y)).+(x_0),
> > x.*(y).*(2.0).+(y_0), x_0, y_0, iterations.+(1))
> > else
> > new Tuple3(scala.Int.box(iterations), scala.Double.box(x),
> > scala.Double.box(y))
> > }
> > };
>
> > ----------------------------------------------------
> > I tried this way as well, but it didn't work
>
> > case class SpecializedTupleT3 [ <at> specialized(Int) TT1,
> > <at> specialized(Double)
> > TT2,
> > <at> specialized(Double)
> > TT3](_1:TT1, _2:TT2, _3:TT3)
> > private def getIterations(x:Double, y:Double, x_0:Double,
> > y_0:Double, iterations:
> > Int):SpecializedTupleT3[Int, Double,
> > Double] = {
> > if (iterations < maxIterations && x*x + y*y <= 4)
> > getIterations(x*x - y*y + x_0, x*y*2.0 + y_0, x_0, y_0, iterations
> > +1)
> > else new SpecializedTupleT3[Int, Double, Double](iterations, x, y)
> > }
>
> > -------------
>
> > Thanks