From 487b7237a730469fc4f8a501a93f78c2bbafad51 Mon Sep 17 00:00:00 2001 From: Ira Rice Date: Wed, 28 Jan 2009 13:43:46 -0700 Subject: Removed manual trimmings in exchange for using trim.h instead. Signed-off-by: Ira Rice --- src/being.cpp | 12 +++--------- src/resources/itemdb.cpp | 10 ++-------- 2 files changed, 5 insertions(+), 17 deletions(-) (limited to 'src') diff --git a/src/being.cpp b/src/being.cpp index 985be69c..9de03502 100644 --- a/src/being.cpp +++ b/src/being.cpp @@ -46,7 +46,8 @@ #include "utils/dtor.h" #include "utils/gettext.h" -#include "utils/tostring.h" +#include "utils/tostring.h" +#include "utils/trim.h" #include "utils/xml.h" int Being::instances = 0; @@ -176,14 +177,7 @@ void Being::setSpeech(const std::string &text, Uint32 time) mSpeech = text; // Trim whitespace - while (mSpeech[0] == ' ') - { - mSpeech = mSpeech.substr(1, mSpeech.size()); - } - while (mSpeech[mSpeech.size()] == ' ') - { - mSpeech = mSpeech.substr(0, mSpeech.size() - 1); - } + trim(mSpeech); // check for links std::string::size_type start = mSpeech.find('['); diff --git a/src/resources/itemdb.cpp b/src/resources/itemdb.cpp index 773febd7..384efdf1 100644 --- a/src/resources/itemdb.cpp +++ b/src/resources/itemdb.cpp @@ -31,6 +31,7 @@ #include "../utils/dtor.h" #include "../utils/gettext.h" +#include "../utils/trim.h" #include "../utils/xml.h" namespace @@ -125,14 +126,7 @@ void ItemDB::load() if (itr == mNamedItemInfos.end()) { std::string temp = name; - while (temp[0] == ' ') - { - temp = temp.substr(1, temp.size()); - } - while (temp[temp.size()] == ' ') - { - temp = temp.substr(0, temp.size() - 1); - } + trim(temp); for (unsigned int i = 0; i < temp.size(); i++) { -- cgit v1.2.3-70-g09d2