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

David Blasby dblasby at refractions.net
Fri Nov 15 13:11:09 EST 2002


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





More information about the geos-devel mailing list