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
Index: src/uk/me/parabola/imgfmt/app/trergn/Point.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/imgfmt/app/trergn/Point.java	(revision 3437)
+++ src/uk/me/parabola/imgfmt/app/trergn/Point.java	(revision )
@@ -119,8 +119,6 @@
 	}
 
 	public POIRecord getPOIRecord() {
-		if (poi == null)
-			return new POIRecord();
 		return poi;
 	}
 
Index: src/uk/me/parabola/mkgmap/combiners/MdrBuilder.java
IDEA additional info:
Subsystem: com.intellij.openapi.diff.impl.patch.CharsetEP
<+>UTF-8
===================================================================
--- src/uk/me/parabola/mkgmap/combiners/MdrBuilder.java	(revision 3437)
+++ src/uk/me/parabola/mkgmap/combiners/MdrBuilder.java	(revision )
@@ -290,9 +290,11 @@
 				// This is not a city, but we have information about which city
 				// it is in.  If so then add the mdr5 record number of the city.
 				POIRecord poi = p.getPOIRecord();
+				if (poi != null) {
-				City c = poi.getCity();
-				if (c != null)
-					mdrCity = getMdr5FromCity(maps, c);
+					City c = poi.getCity();
+					if (c != null)
+						mdrCity = getMdr5FromCity(maps, c);
+				}
 				isCity = false;
 			}
 
_______________________________________________
mkgmap-dev mailing list
[email protected]
http://www.mkgmap.org.uk/mailman/listinfo/mkgmap-dev

Reply via email to