1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-07-25 17:37:37 +00:00

AK+Everywhere: Consolidate String::index_of() and String::find()

We had two functions for doing mostly the same thing. Combine both
of them into String::find() and use that everywhere.

Also add some tests to cover basic behavior.
This commit is contained in:
Andreas Kling 2021-05-24 11:50:46 +02:00
parent 875a2cbb71
commit de395a3df2
12 changed files with 36 additions and 30 deletions

View file

@ -82,7 +82,7 @@ HunkLocation parse_hunk_location(const String& location_line)
size_t length { 0 };
};
auto parse_start_and_length_pair = [](const String& raw) {
auto index_of_separator = raw.index_of(",").value();
auto index_of_separator = raw.find(',').value();
auto start = raw.substring(0, index_of_separator);
auto length = raw.substring(index_of_separator + 1, raw.length() - index_of_separator - 1);
auto res = StartAndLength { start.to_uint().value() - 1, length.to_uint().value() - 1 };