MCPcopy Create free account
hub / github.com/Tencent/MMKV / removeValuesForKeys

Method removeValuesForKeys

Core/MMKV.cpp:1161–1201  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

1159}
1160
1161bool MMKV::removeValuesForKeys(const vector<string> &arrKeys) {
1162 if (isReadOnly()) {
1163 MMKVWarning("[%s] file readonly", m_mmapID.c_str());
1164 return false;
1165 }
1166 if (arrKeys.empty()) {
1167 return true;
1168 }
1169 if (arrKeys.size() == 1) {
1170 return removeValueForKey(arrKeys[0]);
1171 }
1172
1173 SCOPED_LOCK(m_lock);
1174 SCOPED_LOCK(m_exclusiveProcessLock);
1175 checkLoadData();
1176
1177 size_t deleteCount = 0;
1178 if (m_crypter) {
1179 for (const auto &key : arrKeys) {
1180 auto itr = m_dicCrypt->find(key);
1181 if (itr != m_dicCrypt->end()) {
1182 m_dicCrypt->erase(itr);
1183 deleteCount++;
1184 }
1185 }
1186 } else {
1187 for (const auto &key : arrKeys) {
1188 auto itr = m_dic->find(key);
1189 if (itr != m_dic->end()) {
1190 m_dic->erase(itr);
1191 deleteCount++;
1192 }
1193 }
1194 }
1195 if (deleteCount > 0) {
1196 m_hasFullWriteback = false;
1197
1198 return fullWriteback();
1199 }
1200 return true;
1201}
1202
1203#endif // MMKV_APPLE
1204

Callers 10

removeValuesForKeysFunction · 0.45
removeValuesForKeysFunction · 0.45
functionalTestFunction · 0.45
removeValuesForKeysFunction · 0.45
removeValuesForKeysFunction · 0.45
removeValuesForKeysFunction · 0.45
RemoveKeysMethod · 0.45
functionalTestFunction · 0.45
testRemoveFunction · 0.45
functionalTestFunction · 0.45

Calls 2

isReadOnlyFunction · 0.70
removeValueForKeyFunction · 0.50

Tested by 2

testRemoveFunction · 0.36
functionalTestFunction · 0.36