OLD | NEW |
1 /* | 1 /* |
2 * This file is part of Adblock Plus <https://adblockplus.org/>, | 2 * This file is part of Adblock Plus <https://adblockplus.org/>, |
3 * Copyright (C) 2006-present eyeo GmbH | 3 * Copyright (C) 2006-present eyeo GmbH |
4 * | 4 * |
5 * Adblock Plus is free software: you can redistribute it and/or modify | 5 * Adblock Plus is free software: you can redistribute it and/or modify |
6 * it under the terms of the GNU General Public License version 3 as | 6 * it under the terms of the GNU General Public License version 3 as |
7 * published by the Free Software Foundation. | 7 * published by the Free Software Foundation. |
8 * | 8 * |
9 * Adblock Plus is distributed in the hope that it will be useful, | 9 * Adblock Plus is distributed in the hope that it will be useful, |
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of | 10 * but WITHOUT ANY WARRANTY; without even the implied warranty of |
(...skipping 121 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
132 size_type find(value_type c, size_type pos = 0) const | 132 size_type find(value_type c, size_type pos = 0) const |
133 { | 133 { |
134 for (size_type i = pos; i < length(); ++i) | 134 for (size_type i = pos; i < length(); ++i) |
135 if (mBuf[i] == c) | 135 if (mBuf[i] == c) |
136 return i; | 136 return i; |
137 return npos; | 137 return npos; |
138 } | 138 } |
139 | 139 |
140 size_type find(const String& str, size_type pos = 0) const | 140 size_type find(const String& str, size_type pos = 0) const |
141 { | 141 { |
142 if (pos > LENGTH_MASK || pos + str.length() > length()) | 142 return find(str.mBuf, pos, str.length()); |
| 143 } |
| 144 |
| 145 size_type find(const value_type* str, size_type pos, size_type count) const |
| 146 { |
| 147 if (pos > LENGTH_MASK || pos + count > length()) |
143 return npos; | 148 return npos; |
144 | 149 |
145 if (!str.length()) | 150 if (!count) |
146 return pos; | 151 return pos; |
147 | 152 |
148 for (; pos + str.length() <= length(); ++pos) | 153 for (; pos + count <= length(); ++pos) |
149 { | 154 { |
150 if (mBuf[pos] == str[0] && | 155 if (mBuf[pos] == str[0] && |
151 std::memcmp(mBuf + pos, str.mBuf, sizeof(value_type) * str.length()) =
= 0) | 156 std::memcmp(mBuf + pos, str, sizeof(value_type) * count) == 0) |
152 { | 157 { |
153 return pos; | 158 return pos; |
154 } | 159 } |
155 } | 160 } |
156 | 161 |
157 return npos; | 162 return npos; |
158 } | 163 } |
159 | 164 |
160 size_type rfind(value_type c, size_type pos = npos) const | 165 size_type rfind(value_type c, size_type pos = npos) const |
161 { | 166 { |
(...skipping 282 matching lines...) Expand 10 before | Expand all | Expand 10 after Loading... |
444 } | 449 } |
445 }; | 450 }; |
446 | 451 |
447 #ifdef INSIDE_TESTS | 452 #ifdef INSIDE_TESTS |
448 inline std::ostream& operator<<(std::ostream& os, const OwnedString& str) | 453 inline std::ostream& operator<<(std::ostream& os, const OwnedString& str) |
449 { | 454 { |
450 return os << static_cast<const String&>(str); | 455 return os << static_cast<const String&>(str); |
451 } | 456 } |
452 #endif | 457 #endif |
453 ABP_NS_END | 458 ABP_NS_END |
OLD | NEW |