Cuisine UI speed improvement #2924

Merged
root merged 6 commits from issue-285-suisine-search into master 2022-07-08 22:31:40 +00:00
Member

Moved osm::Cuisines::Instance() out of the loop for Editor.nativeTranslateCuisines(...) method.

After PR #2921 is closed I found that Editor.cpp could be improved a little too.

Is it possible to create new PR from a branch which was previously merged to master?

Moved `osm::Cuisines::Instance()` out of the loop for `Editor.nativeTranslateCuisines(...)` method. After PR #2921 is closed I found that Editor.cpp could be improved a little too. Is it possible to create new PR from a branch which was previously merged to master?
vng commented 2022-07-05 12:37:14 +00:00 (Migrated from github.com)

Just rebase your branch behind new master.

Just rebase your branch behind new master.
vng commented 2022-07-05 13:38:49 +00:00 (Migrated from github.com)

BTW, previous change was in util_StringUtils_nativeFilterContainsNormalized.
Don't you think that it's very common function to call Cuisines.Translate? I'm not familiar with editor flow in Android, but now I see that there is a jni Editor.cpp

Is it possible to incapsulate all Cuisines.Translate routine in Editor context?

BTW, previous change was in util_StringUtils_nativeFilterContainsNormalized. Don't you think that it's very common function to call Cuisines.Translate? I'm not familiar with editor flow in Android, but now I see that there is a jni Editor.cpp Is it possible to incapsulate all Cuisines.Translate routine in Editor context?
Author
Member

@vng you are right. I shouldn't change util_StringUtils_nativeFilterContainsNormalized in PR #2921. This function should work for all strings (no cuisine translation). So I added new function Editor.nativeFilterCuisinesKeys implemented in C++ function ..._editor_Editor_nativeFilterCuisinesKeys. This new function searches in keys and in translated cuisine labels.

Reverted util_StringUtils_nativeFilterContainsNormalized.

@vng you are right. I shouldn't change `util_StringUtils_nativeFilterContainsNormalized` in PR #2921. This function should work for all strings (no cuisine translation). So I added new function `Editor.nativeFilterCuisinesKeys` implemented in C++ function `..._editor_Editor_nativeFilterCuisinesKeys`. This new function searches in keys and in translated cuisine labels. Reverted `util_StringUtils_nativeFilterContainsNormalized`.
vng (Migrated from github.com) approved these changes 2022-07-06 13:11:27 +00:00
biodranik (Migrated from github.com) approved these changes 2022-07-06 20:15:50 +00:00
biodranik (Migrated from github.com) left a comment

LGTM with minor comments.

LGTM with minor comments.
biodranik (Migrated from github.com) commented 2022-07-06 20:10:43 +00:00
  std::string const substr = jni::ToNativeString(env, jSubstr);
```suggestion std::string const substr = jni::ToNativeString(env, jSubstr); ```
biodranik (Migrated from github.com) commented 2022-07-06 20:12:23 +00:00
    std::string const str = jni::ToNativeString(env, static_cast<jstring>(env->GetObjectArrayElement(src, i)));
```suggestion std::string const str = jni::ToNativeString(env, static_cast<jstring>(env->GetObjectArrayElement(src, i))); ```
biodranik (Migrated from github.com) commented 2022-07-06 20:14:06 +00:00
    std::string const key = jni::ToNativeString(env, static_cast<jstring>(env->GetObjectArrayElement(jKeys, i)));
```suggestion std::string const key = jni::ToNativeString(env, static_cast<jstring>(env->GetObjectArrayElement(jKeys, i))); ```
@ -37,15 +37,14 @@ Java_com_mapswithme_util_StringUtils_nativeContainsNormalized(JNIEnv * env, jcla
JNIEXPORT jobjectArray JNICALL
Java_com_mapswithme_util_StringUtils_nativeFilterContainsNormalized(JNIEnv * env, jclass thiz, jobjectArray src, jstring jSubstr)
biodranik (Migrated from github.com) commented 2022-07-06 20:14:34 +00:00
  std::string const substr = jni::ToNativeString(env, jSubstr);
```suggestion std::string const substr = jni::ToNativeString(env, jSubstr); ```
biodranik (Migrated from github.com) commented 2022-07-06 20:15:08 +00:00
    std::string const str = jni::ToNativeString(env, static_cast<jstring>(env->GetObjectArrayElement(src, i)));
```suggestion std::string const str = jni::ToNativeString(env, static_cast<jstring>(env->GetObjectArrayElement(src, i))); ```
strump reviewed 2022-07-07 08:07:54 +00:00
Author
Member

Fixed according to review comments.

Fixed according to review comments.
Author
Member

@biodranik I think maybe instead of 2 native calls I should copy nativeGetCuisines implementation into nativeFilterCuisinesKeys ?
And this line would look like:

Editor.nativeFilterCuisinesKeys(filter);
@biodranik I think maybe instead of 2 native calls I should copy `nativeGetCuisines` implementation into `nativeFilterCuisinesKeys` ? And this line would look like: ``` Editor.nativeFilterCuisinesKeys(filter); ```
biodranik (Migrated from github.com) reviewed 2022-07-07 21:26:47 +00:00
biodranik (Migrated from github.com) commented 2022-07-07 21:26:46 +00:00

It's a good idea if the code can be reused and made simple. An empty filter returns everything, a non-empty filter returns filtered results.

It's a good idea if the code can be reused and made simple. An empty filter returns everything, a non-empty filter returns filtered results.
strump reviewed 2022-07-08 07:43:17 +00:00
Author
Member

Ok, I've simplified Editor.nativeFilterCuisinesKeys(String) function. Please review.

Ok, I've simplified `Editor.nativeFilterCuisinesKeys(String)` function. Please review.
vng (Migrated from github.com) approved these changes 2022-07-08 08:25:55 +00:00
biodranik (Migrated from github.com) approved these changes 2022-07-08 22:31:14 +00:00
biodranik (Migrated from github.com) left a comment

Super, thanks! Code became cleaner and faster ;-)

Super, thanks! Code became cleaner and faster ;-)
This repo is archived. You cannot comment on pull requests.
No reviewers
No labels
Accessibility
Accessibility
Address
Address
Android
Android
Android Auto
Android Auto
Android Automotive (AAOS)
Android Automotive (AAOS)
API
API
AppGallery
AppGallery
AppStore
AppStore
Battery and Performance
Battery and Performance
Blocker
Blocker
Bookmarks and Tracks
Bookmarks and Tracks
Borders
Borders
Bug
Bug
Build
Build
CarPlay
CarPlay
Classificator
Classificator
Community
Community
Core
Core
CrashReports
CrashReports
Cycling
Cycling
Desktop
Desktop
DevEx
DevEx
DevOps
DevOps
dev_sandbox
dev_sandbox
Directions
Directions
Documentation
Documentation
Downloader
Downloader
Drape
Drape
Driving
Driving
Duplicate
Duplicate
Editor
Editor
Elevation
Elevation
Enhancement
Enhancement
Epic
Epic
External Map Datasets
External Map Datasets
F-Droid
F-Droid
Fonts
Fonts
Frequently User Reported
Frequently User Reported
Fund
Fund
Generator
Generator
Good first issue
Good first issue
Google Play
Google Play
GPS
GPS
GSoC
GSoC
iCloud
iCloud
Icons
Icons
iOS
iOS
Legal
Legal
Linux Desktop
Linux Desktop
Linux packaging
Linux packaging
Linux Phone
Linux Phone
Mac OS
Mac OS
Map Data
Map Data
Metro
Metro
Navigation
Navigation
Need Feedback
Need Feedback
Night Mode
Night Mode
NLnet 2024-06-281
NLnet 2024-06-281
No Feature Parity
No Feature Parity
Opening Hours
Opening Hours
Outdoors
Outdoors
POI Info
POI Info
Privacy
Privacy
Public Transport
Public Transport
Raw Idea
Raw Idea
Refactoring
Refactoring
Regional
Regional
Regression
Regression
Releases
Releases
RoboTest
RoboTest
Route Planning
Route Planning
Routing
Routing
Ruler
Ruler
Search
Search
Security
Security
Styles
Styles
Tests
Tests
Track Recording
Track Recording
Translations
Translations
TTS
TTS
UI
UI
UX
UX
Walk Navigation
Walk Navigation
Watches
Watches
Web
Web
Wikipedia
Wikipedia
Windows
Windows
Won't fix
Won't fix
World Map
World Map
No milestone
No project
No assignees
2 participants
Due date
The due date is invalid or out of range. Please use the format "yyyy-mm-dd".

No due date set.

Dependencies

No dependencies set.

Reference: organicmaps/organicmaps-tmp#2924
No description provided.