always internalize tag key Strings

This commit is contained in:
Hannes Janetzek 2013-05-07 16:09:50 +02:00
parent 97658f3ab1
commit 05d4dba5fc

View File

@ -44,7 +44,6 @@ public class Tag {
public static final String TAG_KEY_AMENITY = "amenity".intern(); public static final String TAG_KEY_AMENITY = "amenity".intern();
/** /**
* The key of the elevation OpenStreetMap tag. * The key of the elevation OpenStreetMap tag.
*/ */
@ -101,12 +100,11 @@ public class Tag {
public Tag(String key, String value, boolean intern) { public Tag(String key, String value, boolean intern) {
this.key = key.intern(); this.key = key.intern();
if (intern) { if (intern)
this.value = (value == null ? null : value.intern()); this.value = (value == null ? null : value.intern());
} else
else {
this.value = value; this.value = value;
}
this.intern = intern; this.intern = intern;
} }
@ -119,11 +117,14 @@ public class Tag {
} }
Tag other = (Tag) obj; Tag other = (Tag) obj;
if (this.key != other.key)
return false;
if (this.intern && other.intern) { if (this.intern && other.intern) {
if ((this.key == other.key) && (this.value == other.value)) if (this.value == other.value)
return true; return true;
} else { } else {
if ((this.key.equals(other.key)) && (this.value.equals(other.value))) if (this.value.equals(other.value))
return true; return true;
} }
return false; return false;