[geos-devel] Pass by reference in Java and C++

Martin Davis mbdavis at VividSolutions.com
Tue Nov 12 11:57:34 EST 2002


You got it right, Norman - in Java *everything* is passed by reference, whereas in C++ you get a choice.    I think when Yury did the initial translation of the code he stuck very close to the Java way of doing things, partly because it's hard to know without understanding the code fairly well whether passing-by-reference is needed or not (i.e. sometimes you really do want an alias to a shared object).

It would certainly help for anyone who has time to look at the code and see if there's obvious wins to be had by switching to pass-by-value in particular cases.

Martin Davis, Senior Technical Specialist
Vivid Solutions Inc.
Suite #1A-2328 Government Street   Victoria, B.C.   V8T 5G5
Phone: (250) 385 6040    Fax: (250) 385 6046
EMail: mbdavis at vividsolutions.com  Web: www.vividsolutions.com


> -----Original Message-----
> From: Norman Vine [mailto:nhv at cape.com]
> Sent: Monday, November 11, 2002 8:57 AM
> To: geos-devel at geos.refractions.net
> Subject: Re: [geos-devel] Performance of GEOS compared to JTS (Report,
> Nov. 8)
> 
> 
> Martin Davis
> > 
> > I would still expect that the C++ code should be absolutely 
> faster than Java - 
> 
> Me too 
> 
> > so we still have some sleuthing to do.
> 
> < disclaimer> 
>   I know next to nothing about the JAVA 'machine' 
> </>
> 
> Does JAVA pass somethings by reference automatically 
> whereas in C++ you have to explicitly declare this ?
> 
> If so this might explain things as there seems to be a LOT 
> of information being passed on the stack in GEOS which 
> doesn't necessarily need to be.
> 
> Norman
> 
> 
> 
> _______________________________________________
> geos-devel mailing list
> geos-devel at geos.refractions.net
> http://geos.refractions.net/mailman/listinfo/geos-devel
> 




More information about the geos-devel mailing list