react-native-mmkv
react-native-mmkv copied to clipboard
MMKV.cpp std::move on a temporary object - Copy Elision
The following warning is generated during build: gradle warning: warning: moving a temporary object prevents copy elision [-Wpessimizing-move]
This occurs in the generated MMKV.cpp on the bool MMKV::getBytes method, calls std::move on a temporary object, which causes the warning. This potentially causes efficiency issues.
The fix would be:
diff --git a/node_modules/react-native-mmkv/MMKV/Core/MMKV.cpp b/node_modules/react-native-mmkv/MMKV/Core/MMKV.cpp
index eb5b708..a81fe6f 100755
--- a/node_modules/react-native-mmkv/MMKV/Core/MMKV.cpp
+++ b/node_modules/react-native-mmkv/MMKV/Core/MMKV.cpp
@@ -701,7 +701,7 @@ bool MMKV::getBytes(MMKVKey_t key, mmkv::MMBuffer &result) {
if (data.length() > 0) {
try {
CodedInputData input(data.getPtr(), data.length());
- result = std::move(input.readData());
+ result = input.readData();
return true;
} catch (std::exception &exception) {
MMKVError("%s", exception.what());
But since it's a generated file I'm not sure how/if it could be fixed in the source code.
Any updates?
This is a warning. And can be ignored.