Chromium Code Reviews| 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..b604e930bf17c7d4885902b62f97168ec86c3f25 100644 |
| --- a/third_party/WebKit/Source/platform/v8_inspector/V8StringUtil.cpp |
| +++ b/third_party/WebKit/Source/platform/v8_inspector/V8StringUtil.cpp |
| @@ -15,7 +15,7 @@ namespace { |
| String16 findMagicComment(const String16& content, const String16& name, bool multiline, bool* deprecated) |
| { |
| - DCHECK(name.find("=") == kNotFound); |
| + DCHECK(name.find("=") == String16::kNotFound); |
| if (deprecated) |
| *deprecated = false; |
| @@ -27,7 +27,7 @@ String16 findMagicComment(const String16& content, const String16& name, bool mu |
| size_t closingCommentPos = 0; |
| while (true) { |
| pos = content.reverseFind(name, pos); |
| - if (pos == kNotFound) |
| + if (pos == String16::kNotFound) |
| return String16(); |
| // Check for a /\/[\/*][@#][ \t]/ regexp (length of 4) before found name. |
| @@ -48,7 +48,7 @@ String16 findMagicComment(const String16& content, const String16& name, bool mu |
| continue; |
| if (multiline) { |
| closingCommentPos = content.find("*/", equalSignPos + 1); |
| - if (closingCommentPos == kNotFound) |
| + if (closingCommentPos == String16::kNotFound) |
| return String16(); |
| } |
| @@ -66,13 +66,13 @@ String16 findMagicComment(const String16& content, const String16& name, bool mu |
| : content.substring(urlPos); |
| size_t newLine = match.find("\n"); |
| - if (newLine != kNotFound) |
| + if (newLine != String16::kNotFound) |
| match = match.substring(0, newLine); |
| match = match.stripWhiteSpace(); |
| - 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("[](){}+-*.,?\\^$|"); |
|
caseq
2016/08/13 00:28:54
unused now?
dgozman
2016/08/13 04:49:59
Done.
|
| 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,10 +101,11 @@ std::unique_ptr<std::vector<unsigned>> lineEndings(const String16& text) |
| { |
| std::unique_ptr<std::vector<unsigned>> result(new std::vector<unsigned>()); |
| + const String16 lineEndString = "\n"; |
| unsigned start = 0; |
| while (start < text.length()) { |
| - size_t lineEnd = text.find('\n', start); |
| - if (lineEnd == kNotFound) |
| + size_t lineEnd = text.find(lineEndString, start); |
| + if (lineEnd == String16::kNotFound) |
| break; |
| result->push_back(static_cast<unsigned>(lineEnd)); |
| @@ -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; |