logo separator

[mkgmap-dev] point.getPOIRecord

From Steve Ratcliffe steve at parabola.me.uk on Fri Feb 6 13:47:08 GMT 2015

Hi Mike

> Which means if getPOIRecord is called twice, it will return a new POIRecord
> each time.
> I suspect the code should be:
>
> 	public POIRecord getPOIRecord() {
> 		if (poi == null)
> 			poi = new POIRecord();
> 		return poi;
> 	}
>
> However, there may be a valid reason for the code being as it is. Any
> thoughts?

That method is only called from one place, and that call just reads one
property from the poi record and does not add anything to it.  So if
you made the change you suggest, then you would end up with an empty
POI record on every point.

Having said that I don't know why the code doesn't just return the null, 
one less null check to make is the only advantage.

The current code is harmless, since the newly created object is
immediately thrown away, but if I were to write it today I would
probably do it as in the attached patch.

..Steve
-------------- next part --------------
A non-text attachment was scrubbed...
Name: poi_record.patch
Type: text/x-patch
Size: 1275 bytes
Desc: not available
URL: <http://www.mkgmap.org.uk/pipermail/mkgmap-dev/attachments/20150206/ac1f78e7/attachment.bin>


More information about the mkgmap-dev mailing list