forked from organicmaps/organicmaps-tmp
[android] Small trick for faster DownloadUI displaying - caching returned country size
This commit is contained in:
parent
dbca54f5f7
commit
7285c28713
1 changed files with 16 additions and 4 deletions
|
@ -96,20 +96,32 @@ extern "C"
|
|||
return env->NewStringUTF(name.c_str());
|
||||
}
|
||||
|
||||
// @TODO Small hack to save time by caching last file size
|
||||
storage::TIndex g_lastCountryIndex(storage::TIndex::INVALID);
|
||||
storage::LocalAndRemoteSizeT g_lastSize(-1, -1);
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_com_mapswithme_maps_DownloadUI_countryLocalSizeInBytes(JNIEnv * env, jobject thiz,
|
||||
jint group, jint country, jint region)
|
||||
{
|
||||
storage::LocalAndRemoteSizeT const s = g_framework->Storage().CountrySizeInBytes(storage::TIndex(group, country, region));
|
||||
return s.first;
|
||||
storage::TIndex const index(group, country, region);
|
||||
if (index == g_lastCountryIndex)
|
||||
return g_lastSize.first;
|
||||
g_lastCountryIndex = index;
|
||||
g_lastSize = g_framework->Storage().CountrySizeInBytes(index);
|
||||
return g_lastSize.first;
|
||||
}
|
||||
|
||||
JNIEXPORT jlong JNICALL
|
||||
Java_com_mapswithme_maps_DownloadUI_countryRemoteSizeInBytes(JNIEnv * env, jobject thiz,
|
||||
jint group, jint country, jint region)
|
||||
{
|
||||
storage::LocalAndRemoteSizeT const s = g_framework->Storage().CountrySizeInBytes(storage::TIndex(group, country, region));
|
||||
return s.second;
|
||||
storage::TIndex const index(group, country, region);
|
||||
if (index == g_lastCountryIndex)
|
||||
return g_lastSize.second;
|
||||
g_lastCountryIndex = index;
|
||||
g_lastSize = g_framework->Storage().CountrySizeInBytes(index);
|
||||
return g_lastSize.second;
|
||||
}
|
||||
|
||||
JNIEXPORT jint JNICALL
|
||||
|
|
Loading…
Add table
Reference in a new issue