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

Everywhere: Remove a bunch of redundant 'AK::' namespace prefixes

This is basically just for consistency, it's quite strange to see
multiple AK container types next to each other, some with and some
without the namespace prefix - we're 'using AK::Foo;' a lot and should
leverage that. :^)
This commit is contained in:
Linus Groh 2021-02-25 21:10:47 +01:00 committed by Andreas Kling
parent be9df404fd
commit e265054c12
73 changed files with 111 additions and 110 deletions

View file

@ -194,7 +194,7 @@ private:
HashMap<Board, int> m_previous_states;
Vector<Move> m_moves;
friend struct AK::Traits<Board>;
friend struct Traits<Board>;
};
template<typename Callback>

View file

@ -114,7 +114,7 @@ u32 CanonicalCode::read_symbol(InputBitStream& stream) const
// FIXME: This is very inefficient and could greatly be improved by implementing this
// algorithm: https://www.hanshq.net/zip.html#huffdec
size_t index;
if (AK::binary_search(m_symbol_codes.span(), code_bits, &index))
if (binary_search(m_symbol_codes.span(), code_bits, &index))
return m_symbol_values[index];
}
}

View file

@ -41,7 +41,7 @@ namespace Core {
static String get_salt()
{
char random_data[12];
AK::fill_with_random(random_data, sizeof(random_data));
fill_with_random(random_data, sizeof(random_data));
StringBuilder builder;
builder.append("$5$");

View file

@ -117,7 +117,7 @@ public:
void deferred_invoke(Function<void(Object&)>);
void save_to(AK::JsonObject&);
void save_to(JsonObject&);
bool set_property(const StringView& name, const JsonValue& value);
JsonValue property(const StringView& name) const;

View file

@ -64,7 +64,7 @@ public:
return { UnsignedBigInteger::create_invalid(), false };
}
static SignedBigInteger import_data(const AK::StringView& data) { return import_data((const u8*)data.characters_without_null_termination(), data.length()); }
static SignedBigInteger import_data(const StringView& data) { return import_data((const u8*)data.characters_without_null_termination(), data.length()); }
static SignedBigInteger import_data(const u8* ptr, size_t length);
size_t export_data(Bytes, bool remove_leading_zeros = false) const;

View file

@ -42,7 +42,7 @@ class UnsignedBigInteger {
public:
UnsignedBigInteger(u32 x) { m_words.append(x); }
explicit UnsignedBigInteger(AK::Vector<u32, STARTING_WORD_SIZE>&& words)
explicit UnsignedBigInteger(Vector<u32, STARTING_WORD_SIZE>&& words)
: m_words(move(words))
{
}
@ -53,7 +53,7 @@ public:
static UnsignedBigInteger create_invalid();
static UnsignedBigInteger import_data(const AK::StringView& data) { return import_data((const u8*)data.characters_without_null_termination(), data.length()); }
static UnsignedBigInteger import_data(const StringView& data) { return import_data((const u8*)data.characters_without_null_termination(), data.length()); }
static UnsignedBigInteger import_data(const u8* ptr, size_t length)
{
return UnsignedBigInteger(ptr, length);
@ -64,7 +64,7 @@ public:
static UnsignedBigInteger from_base10(const String& str);
String to_base10() const;
const AK::Vector<u32, STARTING_WORD_SIZE>& words() const { return m_words; }
const Vector<u32, STARTING_WORD_SIZE>& words() const { return m_words; }
void set_to_0();
void set_to(u32 other);
@ -116,7 +116,7 @@ private:
static constexpr size_t BITS_IN_WORD = 32;
// Little endian
// m_word[0] + m_word[1] * 256 + m_word[2] * 65536 + ...
AK::Vector<u32, STARTING_WORD_SIZE> m_words;
Vector<u32, STARTING_WORD_SIZE> m_words;
// Used to indicate a negative result, or a result of an invalid operation
bool m_is_invalid { false };

View file

@ -291,7 +291,7 @@ UnsignedBigInteger random_number(const UnsignedBigInteger& min, const UnsignedBi
// Also, if we're about to crash anyway, at least produce a nice error:
VERIFY(size < 8 * MiB);
u8 buf[size];
AK::fill_with_random(buf, size);
fill_with_random(buf, size);
UnsignedBigInteger random { buf, size };
// At this point, `random` is a large number, in the range [0, 256^size).
// To get down to the actual range, we could just compute random % range.

View file

@ -57,7 +57,7 @@ public:
auto em_length = (em_bits + 7) / 8;
u8 salt[SaltLength];
AK::fill_with_random(salt, SaltLength);
fill_with_random(salt, SaltLength);
if (em_length < hash_length + SaltLength + 2) {
dbgln("Ooops...encoding error");

View file

@ -358,12 +358,12 @@ void RSA_PKCS1_EME::encrypt(ReadonlyBytes in, Bytes& out)
// FIXME: Without this assertion, GCC refuses to compile due to a memcpy overflow(!?)
VERIFY(ps_length < 16384);
AK::fill_with_random(ps, ps_length);
fill_with_random(ps, ps_length);
// since arc4random can create zeros (shocking!)
// we have to go through and un-zero the zeros
for (size_t i = 0; i < ps_length; ++i)
while (!ps[i])
AK::fill_with_random(ps + i, 1);
fill_with_random(ps + i, 1);
u8 paddings[] { 0x00, 0x02 };

View file

@ -350,7 +350,7 @@ void AbstractTableView::layout_headers()
int x = frame_thickness() + row_header_width - horizontal_scrollbar().value();
int y = frame_thickness();
int width = AK::max(content_width(), rect().width() - frame_thickness() * 2 - row_header_width - vertical_scrollbar_width);
int width = max(content_width(), rect().width() - frame_thickness() * 2 - row_header_width - vertical_scrollbar_width);
column_header().set_relative_rect(x, y, width, column_header().min_size().height());
}
@ -361,7 +361,7 @@ void AbstractTableView::layout_headers()
int x = frame_thickness();
int y = frame_thickness() + column_header_height - vertical_scrollbar().value();
int height = AK::max(content_height(), rect().height() - frame_thickness() * 2 - column_header_height - horizontal_scrollbar_height);
int height = max(content_height(), rect().height() - frame_thickness() * 2 - column_header_height - horizontal_scrollbar_height);
row_header().set_relative_rect(x, y, row_header().min_size().width(), height);
}

View file

@ -64,7 +64,7 @@ void InputBox::build()
int text_width = widget.font().width(m_prompt);
int title_width = widget.font().width(title()) + 24 /* icon, plus a little padding -- not perfect */;
int max_width = AK::max(text_width, title_width);
int max_width = max(text_width, title_width);
set_rect(x(), y(), max_width + 140, 62);

View file

@ -257,7 +257,7 @@ Variant& Variant::operator=(Variant&& other)
if (&other == this)
return *this;
clear();
move_from(AK::move(other));
move_from(move(other));
return *this;
}

View file

@ -51,7 +51,7 @@ public:
Variant(const Gfx::IntRect&);
Variant(const Gfx::Font&);
Variant(const Gfx::TextAlignment);
Variant(const AK::JsonValue&);
Variant(const JsonValue&);
Variant(Color);
Variant(const Variant&);

View file

@ -178,7 +178,7 @@ void WindowServerConnection::handle(const Messages::WindowClient::KeyDown& messa
key_event->m_key = Key_Invalid;
key_event->m_modifiers = 0;
AK::Utf8View m_utf8_view(emoji_input_dialog->selected_emoji_text().characters());
Utf8View m_utf8_view(emoji_input_dialog->selected_emoji_text().characters());
u32 code_point = *m_utf8_view.begin();
key_event->m_code_point = code_point;

View file

@ -67,7 +67,7 @@ struct PGMLoadingContext {
RefPtr<Gfx::Bitmap> bitmap;
};
static void set_adjusted_pixels(PGMLoadingContext& context, const AK::Vector<Gfx::Color>& color_data)
static void set_adjusted_pixels(PGMLoadingContext& context, const Vector<Gfx::Color>& color_data)
{
size_t index = 0;
for (size_t y = 0; y < context.height; ++y) {

View file

@ -207,7 +207,7 @@ static bool create_bitmap(TContext& context)
}
template<typename TContext>
static void set_pixels(TContext& context, const AK::Vector<Gfx::Color>& color_data)
static void set_pixels(TContext& context, const Vector<Gfx::Color>& color_data)
{
size_t index = 0;
for (size_t y = 0; y < context.height; ++y) {

View file

@ -44,7 +44,7 @@ public:
template<typename T>
constexpr bool read(T& value)
{
AK::Array<u8, sizeof(T)> network_buffer {};
Array<u8, sizeof(T)> network_buffer {};
auto network_value = new (network_buffer.data()) AK::NetworkOrdered<T> {};
auto res = read_bytes(network_buffer.data(), sizeof(T));
value = T(*network_value);

View file

@ -36,7 +36,7 @@ MarkedValueList::MarkedValueList(Heap& heap)
}
MarkedValueList::MarkedValueList(MarkedValueList&& other)
: AK::Vector<Value, 32>(move(static_cast<Vector<Value, 32>&>(other)))
: Vector<Value, 32>(move(static_cast<Vector<Value, 32>&>(other)))
, m_heap(other.m_heap)
{
m_heap.did_create_marked_value_list({}, *this);

View file

@ -33,7 +33,7 @@
namespace JS {
class MarkedValueList : public AK::Vector<Value, 32> {
class MarkedValueList : public Vector<Value, 32> {
AK_MAKE_NONCOPYABLE(MarkedValueList);
public:
@ -55,4 +55,5 @@ public:
private:
Heap& m_heap;
};
}

View file

@ -251,12 +251,12 @@ void TLSv12::build_random(PacketBuilder& builder)
u8 random_bytes[48];
size_t bytes = 48;
AK::fill_with_random(random_bytes, bytes);
fill_with_random(random_bytes, bytes);
// remove zeros from the random bytes
for (size_t i = 0; i < bytes; ++i) {
if (!random_bytes[i])
random_bytes[i--] = AK::get_random<u8>();
random_bytes[i--] = get_random<u8>();
}
if (m_context.is_server) {

View file

@ -33,7 +33,7 @@ namespace TLS {
ByteBuffer TLSv12::build_hello()
{
AK::fill_with_random(&m_context.local_random, 32);
fill_with_random(&m_context.local_random, 32);
auto packet_version = (u16)m_context.version;
auto version = (u16)m_context.version;

View file

@ -127,7 +127,7 @@ void TLSv12::update_packet(ByteBuffer& packet)
u8 iv[16];
Bytes iv_bytes { iv, 16 };
Bytes { m_context.crypto.local_aead_iv, 4 }.copy_to(iv_bytes);
AK::fill_with_random(iv_bytes.offset(4), 8);
fill_with_random(iv_bytes.offset(4), 8);
memset(iv_bytes.offset(12), 0, 4);
// write the random part of the iv out
@ -164,7 +164,7 @@ void TLSv12::update_packet(ByteBuffer& packet)
VERIFY(buffer_position == buffer.size());
auto iv = ByteBuffer::create_uninitialized(iv_size);
AK::fill_with_random(iv.data(), iv.size());
fill_with_random(iv.data(), iv.size());
// write it into the ciphertext portion of the message
ct.overwrite(header_size, iv.data(), iv.size());

View file

@ -168,7 +168,7 @@ private:
float m_y_scale { 0.0f };
float m_point_width { 0.0f };
float m_point_height { 0.0f };
mutable AK::HashMap<u32, RefPtr<Gfx::Bitmap>> m_cached_glyph_bitmaps;
mutable HashMap<u32, RefPtr<Gfx::Bitmap>> m_cached_glyph_bitmaps;
};
}

View file

@ -45,7 +45,7 @@ private:
void draw_line(Gfx::FloatPoint, Gfx::FloatPoint);
Gfx::IntSize m_size;
AK::Vector<float> m_data;
Vector<float> m_data;
};
class Loca {

View file

@ -171,8 +171,8 @@ private:
StringView m_input;
Utf8View m_utf8_view;
AK::Utf8CodepointIterator m_utf8_iterator;
AK::Utf8CodepointIterator m_prev_utf8_iterator;
Utf8CodepointIterator m_utf8_iterator;
Utf8CodepointIterator m_prev_utf8_iterator;
HTMLToken m_current_token;