add Tag constructor for intern() keys

This commit is contained in:
Hannes Janetzek 2014-06-09 00:45:04 +02:00
parent 2c6a85ee6d
commit 7c995534eb
2 changed files with 16 additions and 13 deletions

View File

@ -68,28 +68,31 @@ public class Tag {
* the value of the tag.
*/
public Tag(String key, String value) {
this.key = (key == null ? null : key.intern());
this.value = (value == null ? null : value.intern());
this.key = key == null ? null : key.intern();
this.value = value == null ? null : value.intern();
this.intern = true;
}
/**
* Create Tag with interned Key.
*
* @param key
* the key of the tag.
* @param value
* the value of the tag.
* @param intern
* @param internValue
* true when value string should be intern()alized.
*/
public Tag(String key, String value, boolean intern) {
this.key = key.intern();
public Tag(String key, String value, boolean internValue) {
this.key = key;
this.value = (value == null || !internValue) ? value : value.intern();
this.intern = internValue;
}
if (intern)
this.value = (value == null ? null : value.intern());
else
this.value = value;
this.intern = intern;
public Tag(String key, String value, boolean internKey, boolean internValue) {
this.key = (key == null || !internKey) ? key : key.intern();
this.value = (value == null || !internValue) ? value : value.intern();
this.intern = internValue;
}
@Override

View File

@ -121,7 +121,7 @@ public class TileDecoder extends PbfDecoder {
mTile, numKeys);
return false;
}
keys[curKey++] = decodeString();
keys[curKey++] = decodeString().intern();
break;
case TAG_TILE_TAG_VALUES:
@ -222,7 +222,7 @@ public class TileDecoder extends PbfDecoder {
|| key == Tag.KEY_ELE)
tag = new Tag(key, val, false);
else
tag = new Tag(key, val, true);
tag = new Tag(key, val, false, true);
mTileTags.add(tag);
}