- reuse element Tag arrays

- use previous elements' RenderInstructions when tags and zoom match
This commit is contained in:
Hannes Janetzek
2013-02-01 01:37:46 +01:00
parent e99a4279bf
commit 8a5ec974a1
3 changed files with 145 additions and 80 deletions

View File

@@ -226,6 +226,8 @@ public class MapDatabase implements IMapDatabase {
mOpenFile = true;
initDecorder();
return OpenResult.SUCCESS;
}
@@ -305,7 +307,19 @@ public class MapDatabase implements IMapDatabase {
private short[] mIndices = new short[10];
private Tag[] mTmpTags = new Tag[20];
private float[] mTmpCoords = new float[MAX_WAY_COORDS];
private float[] mTmpCoords;
private Tag[][] mElementTags;
private void initDecorder() {
// reusable tag set
Tag[][] tags = new Tag[10][];
for (int i = 0; i < 10; i++)
tags[i] = new Tag[i + 1];
mElementTags = tags;
mTmpCoords = new float[MAX_WAY_COORDS];
}
private boolean decode() throws IOException {
@@ -503,8 +517,13 @@ public class MapDatabase implements IMapDatabase {
if (cnt == 0) {
Log.d(TAG, "got no TAG!");
}
Tag[] tags;
if (cnt < 11)
tags = mElementTags[cnt - 1];
else
tags = new Tag[cnt];
Tag[] tags = new Tag[cnt];
for (int i = 0; i < cnt; i++)
tags[i] = tmp[i];