util: removed duplicate string trimming function
Signed-off-by: Pranam Lashkari <lpranam@collabora.com> Change-Id: Ia150975467d1df8a9d05c8543bcb5d7369d29099
This commit is contained in:
parent
a635f9b8a6
commit
defef6a171
2 changed files with 2 additions and 20 deletions
|
@ -35,9 +35,7 @@ void LockManager::generateLockedCommandList()
|
|||
std::string command;
|
||||
for (std::size_t i = 0; i < commandList.size(); i++)
|
||||
{
|
||||
// just an extra check to make sure any whitespace does not sniff in command
|
||||
// or else command will not be recognized
|
||||
command = Util::trim_whitespace(commandList[i]);
|
||||
command = commandList[i];
|
||||
if (!command.empty())
|
||||
{
|
||||
LockedCommandList.emplace(command);
|
||||
|
@ -134,9 +132,7 @@ void RestrictionManager::generateRestrictedCommandList()
|
|||
std::string command;
|
||||
for (std::size_t i = 0; i < commandList.size(); i++)
|
||||
{
|
||||
// just an extra check to make sure any whitespace does not sniff in command
|
||||
// or else command will not be recognized
|
||||
command = Util::trim_whitespace(commandList[i]);
|
||||
command = commandList[i];
|
||||
if (!command.empty())
|
||||
{
|
||||
RestrictedCommandList.emplace(command);
|
||||
|
|
|
@ -522,20 +522,6 @@ namespace Util
|
|||
return trimmed(std::string(s));
|
||||
}
|
||||
|
||||
// Trim all type of whitespace from left and right
|
||||
inline std::string trim_whitespace(std::string s)
|
||||
{
|
||||
auto last =
|
||||
std::find_if(s.rbegin(), s.rend(), [](char ch) { return !std::isspace(ch); });
|
||||
s.erase(last.base(), s.end()); //trim from right
|
||||
|
||||
auto first =
|
||||
std::find_if(s.begin(), s.end(), [](char ch) { return !std::isspace(ch); });
|
||||
s.erase(s.begin(), first); //trim from left
|
||||
|
||||
return s;
|
||||
}
|
||||
|
||||
/// Return true iff s starts with t.
|
||||
inline bool startsWith(const std::string& s, const std::string& t)
|
||||
{
|
||||
|
|
Loading…
Reference in a new issue