From 9a3b5d48e4f0ce8312891e6fcdd8c8046df2a3aa Mon Sep 17 00:00:00 2001 From: momo5502 Date: Sun, 14 Aug 2016 16:05:57 +0200 Subject: [PATCH] Optimize array access --- src/Components/Modules/RCon.cpp | 2 +- src/Components/Modules/ServerInfo.cpp | 2 +- src/Utils/String.cpp | 2 +- 3 files changed, 3 insertions(+), 3 deletions(-) diff --git a/src/Components/Modules/RCon.cpp b/src/Components/Modules/RCon.cpp index d0b4ae01..450caae0 100644 --- a/src/Components/Modules/RCon.cpp +++ b/src/Components/Modules/RCon.cpp @@ -88,7 +88,7 @@ namespace Components std::string command = data.substr(pos + 1); // B3 sends the password inside quotes :S - if (!password.empty() && password[0] == '"' && password[password.size() - 1] == '"') + if (!password.empty() && password[0] == '"' && password.back() == '"') { password.pop_back(); password.erase(password.begin()); diff --git a/src/Components/Modules/ServerInfo.cpp b/src/Components/Modules/ServerInfo.cpp index 4767e5cc..8a3151e7 100644 --- a/src/Components/Modules/ServerInfo.cpp +++ b/src/Components/Modules/ServerInfo.cpp @@ -271,7 +271,7 @@ namespace Components currentData = currentData.substr(1); } - if (currentData[currentData.size() - 1] == '\"') + if (currentData.back() == '\"') { currentData.pop_back(); } diff --git a/src/Utils/String.cpp b/src/Utils/String.cpp index 96fd97c8..44157047 100644 --- a/src/Utils/String.cpp +++ b/src/Utils/String.cpp @@ -58,7 +58,7 @@ namespace Utils std::string _entry = std::move(token); // Remove trailing 0x0 bytes - while (_entry.size() && !_entry[_entry.size() - 1]) + while (_entry.size() && !_entry.back()) { _entry = _entry.substr(0, _entry.size() - 1); }