MCPcopy Create free account
hub / github.com/axmolengine/axmol / setStringForKey

Method setStringForKey

core/base/UserDefault.cpp:289–331  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

287}
288
289void UserDefault::setStringForKey(const char* pKey, std::string_view value)
290{
291 // ignore empty key
292 if (!pKey || !*pKey)
293 {
294 return;
295 }
296
297 setValueForKey(pKey, value);
298
299#if !USER_DEFAULT_PLAIN_MODE
300 if (_rwmmap)
301 {
302 yasio::obstream obs;
303 if (_encryptEnabled)
304 {
305 ud_write_v_s(this, obs, pKey);
306 ud_write_v_s(this, obs, value);
307 }
308 else
309 {
310 obs.write_v(pKey);
311 obs.write_v(value);
312 }
313
314 if ((_realSize + obs.length() + sizeof(udflen_t)) < _curMapSize)
315 { // fast append entity without flush
316 // increase entities count
317 yasio::obstream::swrite(_rwmmap->data(), 1 + yasio::ibstream::sread<udflen_t>(_rwmmap->data()));
318
319 // append entity
320 ::memcpy(_rwmmap->data() + sizeof(udflen_t) + _realSize, obs.data(), obs.length());
321 _realSize += static_cast<int>(obs.length());
322 }
323 else
324 {
325 flush();
326 }
327 }
328#else
329 flush();
330#endif
331}
332
333void UserDefault::setValueForKey(std::string_view key, std::string_view value)
334{

Callers 2

doTestMethod · 0.45
doTestMethod · 0.45

Calls 5

ud_write_v_sFunction · 0.85
flushFunction · 0.85
write_vMethod · 0.80
lengthMethod · 0.45
dataMethod · 0.45

Tested by 2

doTestMethod · 0.36
doTestMethod · 0.36