speeding up converting process.

master
steffen 12 years ago
parent a96d5ccc04
commit 30cbec28c6

@ -1,6 +1,9 @@
Version 0.0.2: name changed to spOSMroute, since on there had been another Version 0.0.2: name changed to spOSMroute, since on there had been another
OSMroute already. OSMroute already.
============================================================================= =============================================================================
(2013-07-19):
- speeding up converting process.
(2013-06-17): (2013-06-17):
- fixed: softkeyboard is working now with utf8. - fixed: softkeyboard is working now with utf8.

@ -22,7 +22,7 @@
#if !defined(__MINGW32CE__) && !defined(_WIN32_WCE) #if !defined(__MINGW32CE__) && !defined(_WIN32_WCE)
#define ML_BT_SIZE 8 #define ML_BT_SIZE 8
#define ML_BT_TEXT 100 #define ML_BT_TEXT 100
#define MEMORYLEAK_MAX 20000 #define MEMORYLEAK_MAX 50000
#define MEMORYLEAK_MAXMEM 1500000000 #define MEMORYLEAK_MAXMEM 1500000000
#else #else
#define ML_BT_SIZE 2 #define ML_BT_SIZE 2

@ -25,7 +25,7 @@
#include "osmroute.h" #include "osmroute.h"
#include "vector.h" #include "vector.h"
fPoint vec_add (fPoint veca, fPoint vecb) { inline fPoint vec_add (fPoint veca, fPoint vecb) {
fPoint r; fPoint r;
r.x = veca.x + vecb.x; r.x = veca.x + vecb.x;
@ -35,7 +35,7 @@ fPoint vec_add (fPoint veca, fPoint vecb) {
}; };
fPoint vec_sub (fPoint veca, fPoint vecb) { inline fPoint vec_sub (fPoint veca, fPoint vecb) {
fPoint r; fPoint r;
r.x = veca.x - vecb.x; r.x = veca.x - vecb.x;

@ -30,7 +30,6 @@
struct map_hash **mhash = NULL; struct map_hash **mhash = NULL;
int mhash_max = 0; int mhash_max = 0;
int mhash_pos = 0;
struct map_lsstat *mlsstat = NULL; struct map_lsstat *mlsstat = NULL;
int map_busy = 0; int map_busy = 0;
extern int map_search_fd; extern int map_search_fd;
@ -83,7 +82,6 @@ void map_init () {
mhash_max = MAP_HASH_MAX; mhash_max = MAP_HASH_MAX;
mhash = (struct map_hash**) ml_malloc (sizeof (void*) * (mhash_max)); mhash = (struct map_hash**) ml_malloc (sizeof (void*) * (mhash_max));
mhash_pos = mhash_max/2;
for (i = 0; i < mhash_max; i++) for (i = 0; i < mhash_max; i++)
mhash[i] = NULL; mhash[i] = NULL;
}; };

@ -53,7 +53,7 @@
#define MAP_SEARCHLINE_LEN 128 #define MAP_SEARCHLINE_LEN 128
#define MAP_HASH_DEFAULTSIZE 4096 #define MAP_HASH_DEFAULTSIZE 0x20000
#if defined(__MINGW32CE__) || defined(_WIN32_WCE) #if defined(__MINGW32CE__) || defined(_WIN32_WCE)
#define MAP_HASH_MAX 128 #define MAP_HASH_MAX 128

@ -73,37 +73,26 @@ struct map_hash *map_hash_geti (int ilon, int ilat, int loadflags) {
struct map_hash *res = NULL; struct map_hash *res = NULL;
int hi; int hi;
hi = mhash_pos; for (hi = 0; hi < mhash_max; hi++)
if (mhash[hi] && mhash[hi]->pos.ilon == ilon && mhash[hi]->pos.ilat == ilat) res = mhash[hi]; if (mhash[hi] && mhash[hi]->pos.ilon == ilon && mhash[hi]->pos.ilat == ilat) {
else { res = mhash[hi];
hi = mhash_pos+1; for (; hi > 0; hi--) mhash[hi] = mhash[hi-1];
if (hi >= mhash_max) hi = 0; mhash[0] = res;
while (hi != mhash_pos) { return res;
if (mhash[hi] && mhash[hi]->pos.ilon == ilon && mhash[hi]->pos.ilat == ilat) { }
res = mhash[hi];
break;
}
if (++hi >= mhash_max) hi = 0; if (loadflags & MHLOAD_RELOAD) {
if (mhash[mhash_max-1]) {
map_hash_free (mhash[mhash_max-1], 1);
mhash[mhash_max-1] = NULL;
} }
memmove (&mhash[1], &mhash[0], sizeof (struct map_hash*)*mhash_max-1);
if (res == NULL && loadflags & MHLOAD_RELOAD) { mhash[0] = NULL;
res = map_load_hash (ilon, ilat);
if (res) {
if ((--mhash_pos) < 0) mhash_pos = mhash_max-1;
/* add on the givin place, delete old entry */
if (mhash[mhash_pos]) {
map_hash_free (mhash[mhash_pos], 1);
mhash[mhash_pos] = NULL;
}
/* add or update */
if (mhash[mhash_pos] != NULL) d_printf ("%s:%d map_hash_add: memory leak: not free spot", __FILE__, __LINE__);
mhash[mhash_pos] = res;
DELFLAG (res->status, MS_changed); res = map_load_hash (ilon, ilat);
} if (res) {
mhash[0] = res;
DELFLAG (res->status, MS_changed);
} }
} }
@ -116,18 +105,22 @@ struct map_hash *map_hash_geti (int ilon, int ilat, int loadflags) {
* if it already excist exchange it and free the old hash data from the memory * if it already excist exchange it and free the old hash data from the memory
*/ */
int map_hash_add (struct map_hash *mh) { int map_hash_add (struct map_hash *mh) {
int i; int i, fi = -1; /* fi: free hash position */
struct map_hash *mhold = NULL; struct map_hash *mhold = NULL;
if (mh == NULL) return 0; if (mh == NULL) return 0;
/* check if we need to "UPDATE" or to add the hash data */ /* check if we need to "UPDATE" or to add the hash data */
for (mhold = NULL, i = 0; i < mhash_max; i++) if (mhash[i]) { for (mhold = NULL, i = 0; i < mhash_max; i++) {
if (mhash[i]) {
if (mhash[i]->pos.ilon == mh->pos.ilon && mhash[i]->pos.ilat == mh->pos.ilat) { if (mhash[i]->pos.ilon == mh->pos.ilon && mhash[i]->pos.ilat == mh->pos.ilat) {
mhold = mhash[i]; mhold = mhash[i];
fi = i;
break; break;
} }
} }
else if (fi == -1) fi = i;
}
if (mhold != NULL) { /* update !! NOSAVEING !! */ if (mhold != NULL) { /* update !! NOSAVEING !! */
mhash[i] = NULL; mhash[i] = NULL;
@ -135,19 +128,19 @@ int map_hash_add (struct map_hash *mh) {
mhold = NULL; mhold = NULL;
} }
if ((--mhash_pos) < 0) mhash_pos = mhash_max-1;
/* add on the givin place, delete old entry */ /* add on the givin place, delete old entry */
mhold = NULL; if (fi == -1) {
if (mhash[mhash_pos]) { if (mhash[mhash_max-1]) {
map_hash_free (mhash[mhash_pos], 1); map_hash_free (mhash[mhash_max-1], 1);
mhash[mhash_pos] = NULL; mhash[mhash_max-1] = NULL;
}
memmove (&mhash[0], &mhash[1], sizeof (struct map_hash*)*mhash_max-1);
mhash[0] = NULL;
mhash[0] = mh;
} }
else
mhash[fi] = mh;
/* add or update */
if (mhash[mhash_pos] != NULL) d_printf ("%s:%d map_hash_add: memory leak: not free spot", __FILE__, __LINE__);
mhash[mhash_pos] = mh;
return 1; return 1;
}; };
@ -177,7 +170,8 @@ struct map_hash *map_hash_realloc (struct map_hash *mhorg, int memsize) {
struct map_hash *res; struct map_hash *res;
int i = memsize; int i = memsize;
if (i < mhorg->datasize) i = mhorg->datasize; if (i < mhorg->datasize) return res;
res = map_hash_alloc (i); res = map_hash_alloc (i);
map_hash_copy (res, mhorg); map_hash_copy (res, mhorg);

@ -415,7 +415,7 @@ struct s_osm_hashnodes *osm_hashnodes_load (short int hid, int loadhash) {
/* /*
* all data will be saved imedatly so we need only to close the file * all data will be saved immediately so we need only to close the file
*/ */
void osm_hashnodes_free (struct s_osm_hashnodes *hnode) { void osm_hashnodes_free (struct s_osm_hashnodes *hnode) {
if (hnode->hid == -1) return; if (hnode->hid == -1) return;
@ -1378,7 +1378,7 @@ int osm_area_split_add (struct s_osmmarea *marea) {
/******************************************************************** /********************************************************************
* save detail information of the node. This will also create the * save detail information of the node. This will also create the
* search table. * search index.
*/ */
void osm_nodedetail_save (struct osm_nodedetail *onoded, struct osm_node *node) { void osm_nodedetail_save (struct osm_nodedetail *onoded, struct osm_node *node) {
int i, j; int i, j;
@ -1665,7 +1665,7 @@ void osm_processdata (xmlTextReaderPtr reader) {
return; return;
} }
onoded.id = onoded.id; onoded.id = onode.id;
osm_nodedetail_append (&onoded, (char*)k, (char*)v); osm_nodedetail_append (&onoded, (char*)k, (char*)v);
free ((void *)k); free ((void *)k);
free ((void *)v); free ((void *)v);

Loading…
Cancel
Save