Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(1015)

Unified Diff: third_party/WebKit/Source/platform/v8_inspector/V8StringUtil.cpp

Issue 2226863003: [DevTools] Reduce API surface of String16. (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Created 4 years, 4 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
Index: third_party/WebKit/Source/platform/v8_inspector/V8StringUtil.cpp
diff --git a/third_party/WebKit/Source/platform/v8_inspector/V8StringUtil.cpp b/third_party/WebKit/Source/platform/v8_inspector/V8StringUtil.cpp
index 037d91036cfde855929d872547f885e08063f6cf..d98dad6da99698cec59f6de548cc362a1ae0d35d 100644
--- a/third_party/WebKit/Source/platform/v8_inspector/V8StringUtil.cpp
+++ b/third_party/WebKit/Source/platform/v8_inspector/V8StringUtil.cpp
@@ -68,11 +68,11 @@ String16 findMagicComment(const String16& content, const String16& name, bool mu
size_t newLine = match.find("\n");
if (newLine != kNotFound)
match = match.substring(0, newLine);
- match = match.stripWhiteSpace();
+ match = protocol::string16StripWhiteSpace(match);
- String16 disallowedChars("\"' \t");
for (unsigned i = 0; i < match.length(); ++i) {
- if (disallowedChars.find(match[i]) != kNotFound)
+ UChar c = match[i];
+ if (c == '"' || c == '\'' || c == ' ' || c == '\t')
return "";
}
@@ -85,8 +85,12 @@ String16 createSearchRegexSource(const String16& text)
String16 specials("[](){}+-*.,?\\^$|");
for (unsigned i = 0; i < text.length(); i++) {
- if (specials.find(text[i]) != kNotFound)
+ UChar c = text[i];
+ if (c == '[' || c == ']' || c == '(' || c == ')' || c == '{' || c == '}'
+ || c == '+' || c == '-' || c == '*' || c == '.' || c == ',' || c == '?'
+ || c == '\\' || c == '^' || c == '$' || c == '|') {
result.append('\\');
+ }
result.append(text[i]);
}
@@ -97,9 +101,10 @@ std::unique_ptr<std::vector<unsigned>> lineEndings(const String16& text)
{
std::unique_ptr<std::vector<unsigned>> result(new std::vector<unsigned>());
+ String16 lineEndString = "\n";
kozy 2016/08/09 16:40:37 const String16
unsigned start = 0;
while (start < text.length()) {
- size_t lineEnd = text.find('\n', start);
+ size_t lineEnd = text.find(lineEndString, start);
if (lineEnd == kNotFound)
break;
@@ -123,7 +128,7 @@ std::vector<std::pair<int, String16>> scriptRegexpMatchesByLines(const V8Regex&
for (unsigned lineNumber = 0; lineNumber < size; ++lineNumber) {
unsigned lineEnd = endings->at(lineNumber);
String16 line = text.substring(start, lineEnd - start);
- if (line.endsWith('\r'))
+ if (line.length() && line[line.length() - 1] == '\r')
line = line.substring(0, line.length() - 1);
int matchLength;

Powered by Google App Engine
This is Rietveld 408576698