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

AK: Use size_t for the length of strings

Using int was a mistake. This patch changes String, StringImpl,
StringView and StringBuilder to use size_t instead of int for lengths.
Obviously a lot of code needs to change as a result of this.
This commit is contained in:
Andreas Kling 2019-12-09 17:45:40 +01:00
parent 1726c17d0d
commit 6f4c380d95
54 changed files with 387 additions and 377 deletions

View file

@ -4,7 +4,7 @@
static String unescape(const StringView& text)
{
StringBuilder builder;
for (int i = 0; i < text.length(); ++i) {
for (size_t i = 0; i < text.length(); ++i) {
if (text[i] == '\\' && i != text.length() - 1) {
builder.append(text[i + 1]);
i++;
@ -125,10 +125,10 @@ String MDText::render_for_terminal() const
bool MDText::parse(const StringView& str)
{
Style current_style;
int current_span_start = 0;
size_t current_span_start = 0;
int first_span_in_the_current_link = -1;
auto append_span_if_needed = [&](int offset) {
auto append_span_if_needed = [&](size_t offset) {
if (current_span_start != offset) {
Span span {
unescape(str.substring_view(current_span_start, offset - current_span_start)),
@ -138,7 +138,7 @@ bool MDText::parse(const StringView& str)
}
};
for (int offset = 0; offset < str.length(); offset++) {
for (size_t offset = 0; offset < str.length(); offset++) {
char ch = str[offset];
bool is_escape = ch == '\\';
@ -179,7 +179,7 @@ bool MDText::parse(const StringView& str)
offset++;
ASSERT(str[offset] == '(');
offset++;
int start_of_href = offset;
size_t start_of_href = offset;
do
offset++;