aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorMathias Gumz <akira at fluxbox dot org>2010-09-08 19:45:33 (GMT)
committerMathias Gumz <akira at fluxbox dot org>2010-09-08 19:45:33 (GMT)
commit7a149626e60ef089ab3dcdd9b4fceb07250f8e13 (patch)
tree3cfd78c84d0137da40b7d5286e7f56ef71327a35 /src
parent48cc67965b22801b920317b2778639adeeb5c9ac (diff)
downloadfluxbox_pavel-7a149626e60ef089ab3dcdd9b4fceb07250f8e13.zip
fluxbox_pavel-7a149626e60ef089ab3dcdd9b4fceb07250f8e13.tar.bz2
improved 'escapeRememberChars()' routine by traversing the string only once
removed obsolete 'getuint()' function
Diffstat (limited to 'src')
-rw-r--r--src/Remember.cc23
1 files changed, 14 insertions, 9 deletions
diff --git a/src/Remember.cc b/src/Remember.cc
index 80de7ae..f70217e 100644
--- a/src/Remember.cc
+++ b/src/Remember.cc
@@ -224,19 +224,24 @@ void Application::reset() {
224namespace { 224namespace {
225 225
226// replace special chars like ( ) and [ ] with \( \) and \[ \] 226// replace special chars like ( ) and [ ] with \( \) and \[ \]
227static string escapeRememberChars(string str) { 227string escapeRememberChars(const string& str) {
228 if (str.empty()) 228 if (str.empty())
229 return str; 229 return str;
230 230
231 str = FbTk::StringUtil::replaceString(str, "(", "\\("); 231 string escaped_str;
232 str = FbTk::StringUtil::replaceString(str, ")", "\\)"); 232 escaped_str.reserve(str.capacity());
233 str = FbTk::StringUtil::replaceString(str, "[", "\\["); 233
234 str = FbTk::StringUtil::replaceString(str, "]", "\\]"); 234 string::const_iterator i;
235 return str; 235 for (i = str.begin(); i != str.end(); i++) {
236} 236 switch (*i) {
237 case '(': case ')': case '[': case ']':
238 escaped_str += '\\';
239 default:
240 escaped_str += *i;
241 }
242 }
237 243
238bool getuint(const char *val, unsigned int &ret) { 244 return escaped_str;
239 return (sscanf(val, "%u", &ret) == 1);
240} 245}
241 246
242class RememberMenuItem : public FbTk::MenuItem { 247class RememberMenuItem : public FbTk::MenuItem {