Rietveld Code Review Tool
Help | Bug tracker | Discussion group | Source code

Unified Diff: compiled/String.cpp

Issue 29548581: Issue 4128, 5138 - Add Parser and Serializer implemented in C++ Base URL: https://github.com/adblockplus/adblockpluscore.git
Patch Set: Created Sept. 18, 2017, 5:23 p.m.
Use n/p to move between diff chunks; N/P to move between comments.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: compiled/String.cpp
diff --git a/compiled/String.cpp b/compiled/String.cpp
new file mode 100644
index 0000000000000000000000000000000000000000..cdd784d9b19e1c135ec9821f4bcd9a8958b29363
--- /dev/null
+++ b/compiled/String.cpp
@@ -0,0 +1,32 @@
+/*
+* This file is part of Adblock Plus <https://adblockplus.org/>,
+* Copyright (C) 2006-present eyeo GmbH
+*
+* Adblock Plus is free software: you can redistribute it and/or modify
+* it under the terms of the GNU General Public License version 3 as
+* published by the Free Software Foundation.
+*
+* Adblock Plus is distributed in the hope that it will be useful,
+* but WITHOUT ANY WARRANTY; without even the implied warranty of
+* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+* GNU General Public License for more details.
+*
+* You should have received a copy of the GNU General Public License
+* along with Adblock Plus. If not, see <http://www.gnu.org/licenses/>.
+*/
+
+#include "String.h"
+
+DependentString TrimSpaces(const String& value)
+{
+ String::size_type start = 0;
+ auto end = value.length();
+ for (; start < end; start++)
+ if (value[start] > u' ')
Wladimir Palant 2017/12/21 10:30:36 That's an unusual definition of "whitespace," but
sergei 2018/03/01 15:05:24 It's not about whitespaces, it's only for spaces,
+ break;
+
+ for (; end > 0; end--)
Wladimir Palant 2017/12/21 10:30:35 You should check for `end > start` here. Otherwise
sergei 2018/03/01 15:05:24 Done, it's covered in tests.
+ if (value[end - 1] > u' ')
+ break;
+ return DependentString(value, start, end - start);
+}
Wladimir Palant 2017/12/21 10:30:35 All string methods are inlined, why did you put th
sergei 2018/03/01 15:05:25 I moved SplitString into cpp too because when it's

Powered by Google App Engine
This is Rietveld