Skip to content

Commit

Permalink
Everywhere: Remove a bunch of redundant 'AK::' namespace prefixes
Browse files Browse the repository at this point in the history
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. :^)
  • Loading branch information
linusg authored and awesomekling committed Feb 26, 2021
1 parent be9df40 commit e265054
Show file tree
Hide file tree
Showing 73 changed files with 111 additions and 110 deletions.
4 changes: 2 additions & 2 deletions AK/DistinctNumeric.h
Original file line number Diff line number Diff line change
Expand Up @@ -311,9 +311,9 @@ struct Formatter<DistinctNumeric<T, X, Incr, Cmp, Bool, Flags, Shift, Arith>> :
// TODO: Further type aliases?

template<typename T, typename X, auto... Args>
struct AK::Traits<AK::DistinctNumeric<T, X, Args...>> : public AK::GenericTraits<AK::DistinctNumeric<T, X, Args...>> {
struct Traits<AK::DistinctNumeric<T, X, Args...>> : public GenericTraits<AK::DistinctNumeric<T, X, Args...>> {
static constexpr bool is_trivial() { return true; }
static constexpr auto hash(const AK::DistinctNumeric<T, X, Args...>& d) { return AK::Traits<T>::hash(d.value()); }
static constexpr auto hash(const DistinctNumeric<T, X, Args...>& d) { return Traits<T>::hash(d.value()); }
};

using AK::DistinctNumeric;
2 changes: 1 addition & 1 deletion AK/FlyString.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

namespace AK {

struct FlyStringImplTraits : public AK::Traits<StringImpl*> {
struct FlyStringImplTraits : public Traits<StringImpl*> {
static unsigned hash(const StringImpl* s) { return s ? s->hash() : 0; }
static bool equals(const StringImpl* a, const StringImpl* b)
{
Expand Down
2 changes: 1 addition & 1 deletion AK/JsonParser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -231,7 +231,7 @@ Optional<JsonValue> JsonParser::parse_number()
auto number = number_string.to_int<i64>();
if (!number.has_value())
return {};
if (number.value() <= AK::NumericLimits<i32>::max()) {
if (number.value() <= NumericLimits<i32>::max()) {
value = JsonValue((i32)number.value());
} else {
value = JsonValue(number.value());
Expand Down
4 changes: 2 additions & 2 deletions AK/MACAddress.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,11 +79,11 @@ class [[gnu::packed]] MACAddress {

constexpr bool is_zero() const
{
return AK::all_of(m_data.begin(), m_data.end(), [](const auto octet) { return octet == 0; });
return all_of(m_data.begin(), m_data.end(), [](const auto octet) { return octet == 0; });
}

private:
AK::Array<u8, s_mac_address_length> m_data {};
Array<u8, s_mac_address_length> m_data {};
};

static_assert(sizeof(MACAddress) == 6u);
Expand Down
2 changes: 1 addition & 1 deletion AK/String.h
Original file line number Diff line number Diff line change
Expand Up @@ -305,7 +305,7 @@ struct Traits<String> : public GenericTraits<String> {
static unsigned hash(const String& s) { return s.impl() ? s.impl()->hash() : 0; }
};

struct CaseInsensitiveStringTraits : public AK::Traits<String> {
struct CaseInsensitiveStringTraits : public Traits<String> {
static unsigned hash(const String& s) { return s.impl() ? s.to_lowercase().impl()->hash() : 0; }
static bool equals(const String& a, const String& b) { return a.to_lowercase() == b.to_lowercase(); }
};
Expand Down
2 changes: 1 addition & 1 deletion AK/StringUtils.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -184,7 +184,7 @@ Optional<T> convert_to_uint_from_hex(const StringView& str)

T value = 0;
const auto count = str_trimmed.length();
const T upper_bound = AK::NumericLimits<T>::max();
const T upper_bound = NumericLimits<T>::max();

for (size_t i = 0; i < count; i++) {
char digit = str_trimmed[i];
Expand Down
2 changes: 1 addition & 1 deletion AK/StringView.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ Optional<size_t> StringView::find_first_of(const StringView& view) const
{
if (const auto location = AK::find_if(begin(), end(),
[&](const auto c) {
return AK::any_of(view.begin(), view.end(),
return any_of(view.begin(), view.end(),
[&](const auto view_char) {
return c == view_char;
});
Expand Down
2 changes: 1 addition & 1 deletion AK/TestSuite.h
Original file line number Diff line number Diff line change
Expand Up @@ -90,7 +90,7 @@ class TestElapsedTimer {
struct timeval m_started;
};

using TestFunction = AK::Function<void()>;
using TestFunction = Function<void()>;

class TestCase : public RefCounted<TestCase> {
public:
Expand Down
10 changes: 5 additions & 5 deletions AK/Tests/TestAllOf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,13 +31,13 @@

TEST_CASE(should_determine_if_predicate_applies_to_all_elements_in_container)
{
constexpr AK::Array<int, 10> a {};
constexpr Array<int, 10> a {};

static_assert(AK::all_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
static_assert(!AK::all_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));
static_assert(all_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
static_assert(!all_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));

EXPECT(AK::all_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
EXPECT(!AK::all_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));
EXPECT(all_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
EXPECT(!all_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));
}

TEST_MAIN(AllOf)
14 changes: 7 additions & 7 deletions AK/Tests/TestAnyOf.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,15 @@

TEST_CASE(should_determine_if_predicate_applies_to_any_element_in_container)
{
constexpr AK::Array<int, 10> a { 1 };
constexpr Array<int, 10> a { 1 };

static_assert(AK::any_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
static_assert(AK::any_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));
static_assert(!AK::any_of(a.begin(), a.end(), [](auto elem) { return elem == 2; }));
static_assert(any_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
static_assert(any_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));
static_assert(!any_of(a.begin(), a.end(), [](auto elem) { return elem == 2; }));

EXPECT(AK::any_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
EXPECT(AK::any_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));
EXPECT(!AK::any_of(a.begin(), a.end(), [](auto elem) { return elem == 2; }));
EXPECT(any_of(a.begin(), a.end(), [](auto elem) { return elem == 0; }));
EXPECT(any_of(a.begin(), a.end(), [](auto elem) { return elem == 1; }));
EXPECT(!any_of(a.begin(), a.end(), [](auto elem) { return elem == 2; }));
}

TEST_MAIN(AllOf)
2 changes: 1 addition & 1 deletion AK/Tests/TestBadge.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,7 @@

TEST_CASE(should_provide_underlying_type)
{
static_assert(AK::IsSame<int, Badge<int>::Type>::value);
static_assert(IsSame<int, Badge<int>::Type>::value);
}

TEST_MAIN(Badge)
8 changes: 4 additions & 4 deletions AK/Tests/TestFind.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

TEST_CASE(should_return_end_if_not_in_container)
{
constexpr AK::Array<int, 10> a {};
constexpr Array<int, 10> a {};

static_assert(a.end() == AK::find(a.begin(), a.end(), 1));

Expand All @@ -41,7 +41,7 @@ TEST_CASE(should_return_end_if_not_in_container)

TEST_CASE(should_return_iterator_to_first_matching_value_in_container)
{
static constexpr AK::Array<int, 10> a { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };
static constexpr Array<int, 10> a { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };

constexpr auto expected = a.begin() + 4;

Expand All @@ -52,7 +52,7 @@ TEST_CASE(should_return_iterator_to_first_matching_value_in_container)

TEST_CASE(should_return_iterator_to_first_predicate_matching_value_in_container)
{
static constexpr AK::Array<int, 10> a { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };
static constexpr Array<int, 10> a { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };

constexpr auto expected = a.begin() + 4;

Expand All @@ -66,7 +66,7 @@ TEST_CASE(should_return_iterator_to_first_predicate_matching_value_in_container)

TEST_CASE(should_return_index_to_first_predicate_matching_value_in_container)
{
static constexpr AK::Array<int, 10> a { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };
static constexpr Array<int, 10> a { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };

static_assert(4 == AK::find_index(a.begin(), a.end(), 0));

Expand Down
2 changes: 1 addition & 1 deletion AK/Tests/TestSpan.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ TEST_CASE(span_works_with_constant_types)
static constexpr u8 buffer[4] { 1, 2, 3, 4 };
constexpr ReadonlyBytes bytes { buffer, 4 };

static_assert(AK::IsConst<AK::RemoveReference<decltype(bytes[1])>::Type>::value);
static_assert(IsConst<AK::RemoveReference<decltype(bytes[1])>::Type>::value);
static_assert(bytes[2] == 3);
}

Expand Down
6 changes: 3 additions & 3 deletions AK/Tests/TestVector.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -396,7 +396,7 @@ TEST_CASE(should_compare_vectors_of_different_sizes)

TEST_CASE(should_find_value)
{
AK::Vector<int> v { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };
Vector<int> v { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };

const auto expected = v.begin() + 4;

Expand All @@ -405,7 +405,7 @@ TEST_CASE(should_find_value)

TEST_CASE(should_find_predicate)
{
AK::Vector<int> v { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };
Vector<int> v { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };

const auto expected = v.begin() + 4;

Expand All @@ -414,7 +414,7 @@ TEST_CASE(should_find_predicate)

TEST_CASE(should_find_index)
{
AK::Vector<int> v { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };
Vector<int> v { 1, 2, 3, 4, 0, 6, 7, 8, 0, 0 };

EXPECT_EQ(4u, v.find_first_index(0).value());
EXPECT(!v.find_first_index(42).has_value());
Expand Down
4 changes: 2 additions & 2 deletions Kernel/Interrupts/APIC.h
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,8 @@ class APIC {
OwnPtr<Region> m_apic_base;
Vector<OwnPtr<Processor>> m_ap_processor_info;
Vector<Thread*> m_ap_idle_threads;
AK::Atomic<u8> m_apic_ap_count { 0 };
AK::Atomic<u8> m_apic_ap_continue { 0 };
Atomic<u8> m_apic_ap_count { 0 };
Atomic<u8> m_apic_ap_continue { 0 };
u32 m_processor_cnt { 0 };
u32 m_processor_enabled_cnt { 0 };
APICTimer* m_apic_timer { nullptr };
Expand Down
2 changes: 1 addition & 1 deletion Kernel/Process.h
Original file line number Diff line number Diff line change
Expand Up @@ -138,7 +138,7 @@ class Process
~Process();

static Vector<ProcessID> all_pids();
static AK::NonnullRefPtrVector<Process> all_processes();
static NonnullRefPtrVector<Process> all_processes();

template<typename EntryFunction>
RefPtr<Thread> create_kernel_thread(EntryFunction entry, u32 priority, const String& name, u32 affinity = THREAD_AFFINITY_DEFAULT, bool joinable = true)
Expand Down
4 changes: 2 additions & 2 deletions Kernel/SpinLock.h
Original file line number Diff line number Diff line change
Expand Up @@ -69,7 +69,7 @@ class SpinLock {
}

private:
AK::Atomic<BaseType> m_lock { 0 };
Atomic<BaseType> m_lock { 0 };
};

class RecursiveSpinLock {
Expand Down Expand Up @@ -121,7 +121,7 @@ class RecursiveSpinLock {
}

private:
AK::Atomic<FlatPtr> m_lock { 0 };
Atomic<FlatPtr> m_lock { 0 };
u32 m_recursions { 0 };
};

Expand Down
4 changes: 2 additions & 2 deletions Kernel/UnveilNode.h
Original file line number Diff line number Diff line change
Expand Up @@ -50,8 +50,8 @@ struct UnveilMetadata {
bool unveil_inherited_from_root { false }; // true if permissions are inherited from the tree root (/).
};

struct UnveilNode final : public AK::Trie<String, UnveilMetadata, Traits<String>, UnveilNode> {
using AK::Trie<String, UnveilMetadata, Traits<String>, UnveilNode>::Trie;
struct UnveilNode final : public Trie<String, UnveilMetadata, Traits<String>, UnveilNode> {
using Trie<String, UnveilMetadata, Traits<String>, UnveilNode>::Trie;

bool permissions_inherited_from_root() const { return this->metadata_value().unveil_inherited_from_root; }
bool was_explicitly_unveiled() const { return this->metadata_value().explicitly_unveiled; }
Expand Down
2 changes: 1 addition & 1 deletion Meta/Lagom/Fuzzers/FuzzGemini.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
auto gemini = AK::StringView(static_cast<const unsigned char*>(data), size);
auto gemini = StringView(static_cast<const unsigned char*>(data), size);
Gemini::Document::parse(gemini, {});
return 0;
}
2 changes: 1 addition & 1 deletion Meta/Lagom/Fuzzers/FuzzJs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -34,7 +34,7 @@

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
auto js = AK::StringView(static_cast<const unsigned char*>(data), size);
auto js = StringView(static_cast<const unsigned char*>(data), size);
auto lexer = JS::Lexer(js);
auto parser = JS::Parser(lexer);
auto program = parser.parse_program();
Expand Down
2 changes: 1 addition & 1 deletion Meta/Lagom/Fuzzers/FuzzMarkdown.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,7 @@

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
auto markdown = AK::StringView(static_cast<const unsigned char*>(data), size);
auto markdown = StringView(static_cast<const unsigned char*>(data), size);
Markdown::Document::parse(markdown);
return 0;
}
2 changes: 1 addition & 1 deletion Meta/Lagom/Fuzzers/FuzzRegexECMA262.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
auto pattern = AK::StringView(static_cast<const unsigned char*>(data), size);
auto pattern = StringView(static_cast<const unsigned char*>(data), size);
[[maybe_unused]] auto re = Regex<ECMA262>(pattern);
return 0;
}
2 changes: 1 addition & 1 deletion Meta/Lagom/Fuzzers/FuzzRegexPosixExtended.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
auto pattern = AK::StringView(static_cast<const unsigned char*>(data), size);
auto pattern = StringView(static_cast<const unsigned char*>(data), size);
[[maybe_unused]] auto re = Regex<PosixExtended>(pattern);
return 0;
}
2 changes: 1 addition & 1 deletion Meta/Lagom/Fuzzers/FuzzShell.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -31,7 +31,7 @@

extern "C" int LLVMFuzzerTestOneInput(const uint8_t* data, size_t size)
{
auto source = AK::StringView(static_cast<const unsigned char*>(data), size);
auto source = StringView(static_cast<const unsigned char*>(data), size);
Shell::Parser parser(source);
parser.parse();
return 0;
Expand Down
2 changes: 1 addition & 1 deletion Meta/Lagom/Fuzzers/FuzzilliJs.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -232,7 +232,7 @@ int main(int, char**)

int result = 0;

auto js = AK::StringView(static_cast<const unsigned char*>(data_buffer.data()), script_size);
auto js = StringView(static_cast<const unsigned char*>(data_buffer.data()), script_size);

auto lexer = JS::Lexer(js);
auto parser = JS::Parser(lexer);
Expand Down
4 changes: 2 additions & 2 deletions Userland/Applications/DisplaySettings/DisplaySettings.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ void DisplaySettingsWidget::create_frame()

m_wallpaper_combo = *find_descendant_of_type_named<GUI::ComboBox>("wallpaper_combo");
m_wallpaper_combo->set_only_allow_values_from_model(true);
m_wallpaper_combo->set_model(*GUI::ItemListModel<AK::String>::create(m_wallpapers));
m_wallpaper_combo->set_model(*GUI::ItemListModel<String>::create(m_wallpapers));
m_wallpaper_combo->on_change = [this](auto& text, const GUI::ModelIndex& index) {
String path = text;
if (path.starts_with("/") && m_monitor_widget->set_wallpaper(path)) {
Expand Down Expand Up @@ -139,7 +139,7 @@ void DisplaySettingsWidget::create_frame()

m_mode_combo = *find_descendant_of_type_named<GUI::ComboBox>("mode_combo");
m_mode_combo->set_only_allow_values_from_model(true);
m_mode_combo->set_model(*GUI::ItemListModel<AK::String>::create(m_modes));
m_mode_combo->set_model(*GUI::ItemListModel<String>::create(m_modes));
m_mode_combo->on_change = [this](auto&, const GUI::ModelIndex& index) {
m_monitor_widget->set_wallpaper_mode(m_modes.at(index.row()));
m_monitor_widget->update();
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/FileManager/DirectoryView.h
Original file line number Diff line number Diff line change
Expand Up @@ -79,7 +79,7 @@ class DirectoryView final

void refresh();

void launch(const AK::URL&, const LauncherHandler&);
void launch(const URL&, const LauncherHandler&);

Function<void(const StringView& path, bool can_write_in_path)> on_path_change;
Function<void(GUI::AbstractView&)> on_selection_change;
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/KeyboardMapper/KeyPositions.h
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ struct KeyPosition {
int height;
bool enabled;
int map_index;
AK::String name;
String name;
};

#define KEY_COUNT 63
Expand Down
4 changes: 2 additions & 2 deletions Userland/Applications/KeyboardMapper/KeyboardMapperWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -189,7 +189,7 @@ void KeyboardMapperWidget::save_to_file(const StringView& file_name)
auto add_array = [&](String name, u32* values) {
JsonArray items;
for (int i = 0; i < 90; i++) {
AK::StringBuilder sb;
StringBuilder sb;
if (values[i])
sb.append_code_point(values[i]);

Expand Down Expand Up @@ -282,7 +282,7 @@ void KeyboardMapperWidget::set_current_map(const String current_map)
if (index == 0)
continue;

AK::StringBuilder sb;
StringBuilder sb;
sb.append_code_point(map[index]);

m_keys.at(k)->set_text(sb.to_string());
Expand Down
2 changes: 1 addition & 1 deletion Userland/Applications/QuickShow/QSWidget.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -78,7 +78,7 @@ void QSWidget::navigate(Directions direction)
StringBuilder sb;
sb.append("/");
sb.join("/", parts);
AK::String current_dir = sb.to_string();
auto current_dir = sb.to_string();

if (m_files_in_same_dir.is_empty()) {
Core::DirIterator iterator(current_dir, Core::DirIterator::Flags::SkipDots);
Expand Down
2 changes: 1 addition & 1 deletion Userland/Demos/WidgetGallery/main.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -257,7 +257,7 @@ int main(int argc, char** argv)

auto& combobox1 = combo_container.add<GUI::ComboBox>();
combobox1.set_only_allow_values_from_model(true);
combobox1.set_model(*ListViewModel<AK::String>::create(model_items));
combobox1.set_model(*ListViewModel<String>::create(model_items));

auto& combobox2 = combo_container.add<GUI::ComboBox>();
combobox2.set_enabled(false);
Expand Down
Loading

0 comments on commit e265054

Please sign in to comment.