From ba61e831917319bc2d1605ba1e1dbae4af26e639 Mon Sep 17 00:00:00 2001 From: halx99 Date: Thu, 23 Feb 2023 21:59:27 +0800 Subject: [PATCH] Improve UserDefault code style --- core/base/CCUserDefault.cpp | 12 +++++++++--- 1 file changed, 9 insertions(+), 3 deletions(-) diff --git a/core/base/CCUserDefault.cpp b/core/base/CCUserDefault.cpp index f40b363a94..8f28b0769d 100644 --- a/core/base/CCUserDefault.cpp +++ b/core/base/CCUserDefault.cpp @@ -413,14 +413,20 @@ void UserDefault::lazyInit() int count = ibs.read(); for (auto i = 0; i < count; ++i) { - std::string key(ibs.read_v()); - std::string value(ibs.read_v()); if (_encryptEnabled) { + std::string key(ibs.read_v()); + std::string value(ibs.read_v()); this->encrypt(key, AES_DECRYPT); this->encrypt(value, AES_DECRYPT); + updateValueForKey(key, value); + } + else + { + std::string_view key(ibs.read_v()); + std::string_view value(ibs.read_v()); + updateValueForKey(key, value); } - updateValueForKey(key, value); } _realSize = static_cast(ibs.seek(0, SEEK_CUR) - sizeof(udflen_t)); }