[geos-devel] Problem with returning Coordinate* from CoordinateList accessor

Martin Davis mbdavis at VividSolutions.com
Fri Nov 15 13:39:32 EST 2002


Well, if you're right that makes the decision easy!  We just implement   Coordinate getAt(int i).

I would think the function calls in method #2 could be inlined out, however.  I'm hesitant to say a priori which method would be more efficient - compilers do some pretty clever things under the covers.  Probably the only way to say for sure is to try it and see. 

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: David Blasby [mailto:dblasby at refractions.net]
> Sent: Friday, November 15, 2002 10:11 AM
> To: geos-devel at geos.refractions.net
> Subject: Re: [geos-devel] Problem with returning Coordinate* from
> CoordinateList accessor
> 
> 
> Martin,
> 
> I've been assuming that the only way to efficiently do the 
> get() operator was to have actual Coordinates lying around in 
> the CoordinateList.  If you have to make new coordinates 
> everytime you do a get(), you're going to have a really 
> really slow system due to malloc()ing on every call.
> 
> void CoordinateList::getAt(int i, Coordinate& coord)  // 
> calls coord.setX and setY directly
> 
> This is certainly a workable solution in terms of style, but 
> you'll probably find its even slower than it is now.
> Right now, its just doing memcpy() on 24 bytes.  At least I'm 
> assuming the compiler is smart enough to do this.
> 
> If you use the setX and setY and setZ methods, your call to 
> getAt(int) is going to cause 3 more function calls + 
> inefficiently copy the actual 24 bytes.
> 
> dave
> 
> 
> _______________________________________________
> 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