fix: optimization: PVS-Studio warning V815

The 'empty()' method is more efficient for checking if a string is empty compared to comparing it with an empty string literal.

The default constructor 'std::wstring()' is more efficient for creating an empty string compared to using a string literal.

The 'clear()' method is more efficient for clearing a std::wstring compared to assigning it an empty string literal.

Reported by: PVS-Studio
Signed-off-by: Vyacheslav Ivanov <islavaivanov76@gmail.com>
This commit is contained in:
Vyacheslav Ivanov 2024-08-02 02:49:07 +03:00 committed by MihailRis
parent 74a2dd7f6d
commit 5e70837d3f
3 changed files with 3 additions and 3 deletions

View File

@ -126,7 +126,7 @@ void SlotView::draw(const DrawContext* pctx, Assets* assets) {
langs::get(util::str2wstr_utf8(def->caption))
);
} else {
tooltip = L"";
tooltip.clear();
}
}
prevItem = itemid;

View File

@ -66,7 +66,7 @@ wstringsupplier scripting::create_wstring_supplier(
auto str = lua::require_wstring(L, -1); lua::pop(L);
return str;
}
return std::wstring(L"");
return std::wstring();
};
}

View File

@ -201,7 +201,7 @@ void World::deserialize(dynamic::Map* root) {
generator = root->get("generator", generator);
seed = root->get("seed", seed);
if (generator == "") {
if (generator.empty()) {
generator = WorldGenerators::getDefaultGeneratorID();
}
if (auto verobj = root->map("version")) {