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

AK: Make Vector use size_t for its size and capacity

This commit is contained in:
Andreas Kling 2020-02-25 14:49:47 +01:00
parent 9c6f7d3e7d
commit ceec1a7d38
94 changed files with 323 additions and 317 deletions

View file

@ -48,9 +48,9 @@ void DisjointRectSet::shatter()
do {
pass_had_intersections = false;
output.clear_with_capacity();
for (int i = 0; i < m_rects.size(); ++i) {
for (size_t i = 0; i < m_rects.size(); ++i) {
auto& r1 = m_rects[i];
for (int j = 0; j < m_rects.size(); ++j) {
for (size_t j = 0; j < m_rects.size(); ++j) {
if (i == j)
continue;
auto& r2 = m_rects[j];

View file

@ -43,7 +43,7 @@ public:
void add(const Rect&);
bool is_empty() const { return m_rects.is_empty(); }
int size() const { return m_rects.size(); }
size_t size() const { return m_rects.size(); }
void clear() { m_rects.clear(); }
void clear_with_capacity() { m_rects.clear_with_capacity(); }

View file

@ -249,13 +249,13 @@ RefPtr<Gfx::Bitmap> load_gif_impl(const u8* data, size_t data_size)
}
// We exited the block loop after finding a trailer. We should have everything needed.
printf("Image count: %d\n", images.size());
printf("Image count: %zu\n", images.size());
if (images.is_empty())
return nullptr;
for (int i = 0; i < images.size(); ++i) {
for (size_t i = 0; i < images.size(); ++i) {
auto& image = images.at(i);
printf("Image %d: %d,%d %dx%d %d bytes LZW-encoded\n", i, image.x, image.y, image.width, image.height, image.lzw_encoded_bytes.size());
printf("Image %zu: %d,%d %dx%d %zu bytes LZW-encoded\n", i, image.x, image.y, image.width, image.height, image.lzw_encoded_bytes.size());
// FIXME: Decode the LZW-encoded bytes and turn them into an image.
}

View file

@ -357,9 +357,9 @@ template<bool has_alpha, u8 filter_type>
for (int i = 0; i < context.width; ++i) {
auto& pixel = (Pixel&)context.bitmap->scanline(y)[i];
auto& color = context.palette_data.at((int)palette_index[i]);
auto transparency = context.palette_transparency_data.size() >= palette_index[i] + 1
? (int)context.palette_transparency_data.data()[palette_index[i]]
: 0xFF;
auto transparency = context.palette_transparency_data.size() >= palette_index[i] + 1u
? context.palette_transparency_data.data()[palette_index[i]]
: 0xff;
pixel.r = color.r;
pixel.g = color.g;
pixel.b = color.b;

View file

@ -767,7 +767,7 @@ void Painter::draw_text(const Rect& rect, const StringView& raw_text, const Font
static const int line_spacing = 4;
int line_height = font.glyph_height() + line_spacing;
Rect bounding_rect { 0, 0, 0, (lines.size() * line_height) - line_spacing };
Rect bounding_rect { 0, 0, 0, (static_cast<int>(lines.size()) * line_height) - line_spacing };
for (auto& line : lines) {
auto line_width = font.width(line);
@ -795,9 +795,9 @@ void Painter::draw_text(const Rect& rect, const StringView& raw_text, const Font
ASSERT_NOT_REACHED();
}
for (int i = 0; i < lines.size(); ++i) {
for (size_t i = 0; i < lines.size(); ++i) {
auto& line = lines[i];
Rect line_rect { bounding_rect.x(), bounding_rect.y() + i * line_height, bounding_rect.width(), line_height };
Rect line_rect { bounding_rect.x(), bounding_rect.y() + static_cast<int>(i) * line_height, bounding_rect.width(), line_height };
line_rect.intersect(rect);
draw_text_line(line_rect, line, font, alignment, color, elision);
}