summaryrefslogtreecommitdiff
path: root/AK
AgeCommit message (Collapse)Author
2023-01-02AK: Combine SinglyLinkedList and SinglyLinkedListWithCountLenny Maiorani
Using policy based design `SinglyLinkedList` and `SinglyLinkedListWithCount` can be combined into one class which takes a policy to determine how to keep track of the size of the list. The default policy is to use list iteration to count the items in the list each time. The `WithCount` form is a different policy which tracks the size, but comes with the overhead of storing the count and incrementing/decrementing on each modification. This model is extensible to have other forms of counting by implementing only a new policy instead of implementing a totally new type.
2023-01-02AK: Add an option to format numbers with 1000 based unitsArda Cinar
Instead of only allowing 1024-based units.
2023-01-02AK: Make sure no overflow occurs in number_string_with_one_decimalArda Cinar
A possible integer overflow might have occured inside the function in case (number % unit) * 10 did not fit into a u64. So it is verified that this does not happen at the beginning of the function.
2023-01-02AK: Add a human_readable_quantity helper to NumberFormat.hArda Cinar
This can be used for displaying large quantities that are not measured in bytes in a more human-readable format.
2023-01-02AK: Move the functions in NumberFormat.h out of lineArda Cinar
2023-01-02Everywhere: Remove unused includes of AK/IterationDecision.hBen Wiederhake
These instances were detected by searching for files that include IterationDecision.h, but don't match the regex: \\bIterationDecision(?!\.h>)\\b This is the only symbol defined by IterationDecision.h. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-02Everywhere: Remove unused includes of AK/Array.hBen Wiederhake
These instances were detected by searching for files that include Array.h, but don't match the regex: \\b(Array(?!\.h>)|iota_array|integer_sequence_generate_array)\\b These are the three symbols defined by Array.h. In theory, one might use LibCPP to detect things like this automatically, but let's do this one step after another.
2023-01-02Everywhere: Fix badly-formatted includesBen Wiederhake
In 7c5e30daaa615ad3a2ef55222423a747ac0a1227, the focus was "only" on Userland/Libraries/, whereas this commit cleans up the remaining headers in the repo, and any new badly-formatted include.
2022-12-31AK: Prefer VERIFY_NOT_REACHED in ByteBufferNico Weber
2022-12-31AK: Add `CircularBuffer`Lucas CHOLLET
The class is very similar to `CircularDuplexStream` in its behavior. Main differences are that `CircularBuffer`: - does not inherit from `AK::Stream` - uses `ErrorOr` for its API - is heap allocated (and OOM-Safe) This patch also add some tests.
2022-12-29Kernel: Move ScopedCritical.cpp to Kernel base directoryTimon Kruiper
This file does not contain any architecture specific implementations, so we can move it to the Kernel base directory. Also update the relevant include paths.
2022-12-28AK: Fix constructing ErrorOr from ErrorOr of a related typeSam Atkins
Mark other ErrorOr types as friends, and fix a typo in the && constructor, so that we can create an ErrorOr<Core::Object> from an ErrorOr<GUI::Widget>. Also, add some requires() clauses to these constructors so the error messages are clearer.
2022-12-28AK: Add a forgiving_base64_decode helperArda Cinar
According to the specification at https://infra.spec.whatwg.org/#forgiving-base64
2022-12-28AK: Make BigEndian<> and LittleEndian<> work with enum classesNico Weber
2022-12-28AK: Remove ARCH(I386) macroAndreas Kling
2022-12-28AK: Remove i686 supportLiav A
2022-12-27AK: Make StringUtils::matches() handle escaping correctlyFlorian Cramer
Previously any backslash and the character following it were ignored. This commit adds a fall through to match the character following the backslash without checking whether it is "special".
2022-12-26AK: Mark Error::from_ functions as [[nodiscard]]Nico Weber
Prevents mistakes like the one fixed in #16672.
2022-12-26AK: Specialize TypeList for Variant typesTimothy Flynn
This allows callers to use the following semantics: using MyVariant = Variant<Empty, int>; template<typename T> size_t size() { return TypeList<T>::size; } auto s = size<MyVariant>(); This will be needed for an upcoming IPC change, which will result in us knowing the Variant type, but not the underlying variadic types that the Variant holds.
2022-12-26AK: Remove tilde from URL::PercentEncodeSet::EncodeURIAlec Murphy
2022-12-22AK: Rearrange Error's members to reduce its size by 8 bytesTimothy Flynn
This shrinks sizeof(Error) from 32 bytes to 24 bytes, which in turn will shrink sizeof(ErrorOr<T>) by the same amount (in cases where sizeof(T) is less than sizeof(Error)).
2022-12-22AK+Everywhere: Replace all Bitmap::must_create() uses with ::create()Sam Atkins
Well, *someone* has to add some more FIXMEs to keep FIXME Roulette going. :^)
2022-12-22AK: Rename Bitmap::try_create() to ::create()Sam Atkins
This is step 1 to removing `must_create()`.
2022-12-21AK: Calculate elapsed days in `human_readable_time()`Karol Kosek
2022-12-20AK: Add DeprecatedString::find_last(StringView)Agustin Gianni
This adds the the method DeprecatedString::find_last() as wrapper for StringUtils::find_last for the StringView type.
2022-12-20AK: Stop using `DeprecatedString` in Base64 encodingJelle Raaijmakers
2022-12-20AK: Stop using `DeprecatedString` in `UUID`Jelle Raaijmakers
2022-12-19AK: Use __has_builtin() in Checked.hAndreas Kling
Instead of avoiding overflow-checking builtins with AK_COMPILER_CLANG, we can use the preprocessor's __has_builtin() mechanism to check if they are available.
2022-12-17AK+Everywhere: Move custom deleter capability to OwnPtrLenny Maiorani
`OwnPtrWithCustomDeleter` was a decorator which provided the ability to add a custom deleter to `OwnPtr` by wrapping and taking the deleter as a run-time argument to the constructor. This solution means that no additional space is needed for the `OwnPtr` because it doesn't need to store a pointer to the deleter, but comes at the cost of having an extra type that stores a pointer for every instance. This logic is moved directly into `OwnPtr` by adding a template argument that is defaulted to the default deleter for the type. This means that the type itself stores the pointer to the deleter instead of every instance and adds some type safety by encoding the deleter in the type itself instead of taking a run-time argument.
2022-12-16AK: Add a try_ensure() method to HashMapEli Youngs
2022-12-16AK: Support popping an arbitrary element from a HashTableEli Youngs
2022-12-16AK: Synchronize explicit instantiations of to_int and to_uintTimothy Flynn
1. Ensure long and long long are instantiated for to_int. 2. Ensure long and long long are not instantiated for to_uint.
2022-12-15AK: Add `OwnPtrWithCustomDeleter`Lucas CHOLLET
This class is a smart pointer that let you provide a custom deleter to free the pointer. It is quite primitive compared to other smart pointers but can still be useful when interacting with C types that provides a custom `free()` function.
2022-12-15AK: Add Span to Array conversion functionkleines Filmröllchen
2022-12-14AK: Create relative path even if prefix is not an ancestor of the pathPoseydon42
2022-12-14AK: Bring back the AK_DONT_REPLACE_STD #defineAli Mohammad Pur
This was removed in a910961f37d1da9dafb6385e348266746354cf98 in favour of the more general USING_AK_GLOBALLY #define, but Ladybird (and probably other projects) depend on the smaller hammer to include STL headers and keep the USING_AK_GLOBALLY behaviour, so put it back and preserve its behaviour.
2022-12-14Everywhere: Stop shoving things into ::std and mentioning them as suchAli Mohammad Pur
Note that this still keeps the old behaviour of putting things in std by default on serenity so the tools can be happy, but if USING_AK_GLOBALLY is unset, AK behaves like a good citizen and doesn't try to put things in the ::std namespace. std::nothrow_t and its friends get to stay because I'm being told that compilers assume things about them and I can't yeet them into a different namespace...for now.
2022-12-14AK: Make Types.h not export its functions if !USING_AK_GLOBALLYAli Mohammad Pur
2022-12-13AK: Make Variant's index type publickleines Filmröllchen
This will allow the IPC system to use the exact required index type, saving transmission space, once it can send variants.
2022-12-13AK: Fix build with !USING_AK_GLOBALLYAli Mohammad Pur
A couple headers expected names to be in the global namespace, qualify those names to make sure they're resolved even when the names are not exported. One header placed its functions in the global namespace, move those to the AK namespace to make the concepts resolve.
2022-12-12AK: Actually don't include <unistd.h> for windows in Platform.hAli Mohammad Pur
I got the conditions wrong last time, oops :^)
2022-12-12AK: Add a shuffle utility functionArda Cinar
This implements a shuffle function in AK/Random.h which works on any container with size() and curly brace operators. It uses fisher-yates shuffle.
2022-12-12AK: Introduce the `DerivedFrom` conceptLucas CHOLLET
2022-12-12AK: Don't use <random> on windows for ::rand()Ali Mohammad Pur
This is the same as the libc function, just use the libc function.
2022-12-12AK: Don't try to include <unistd.h> on windows for PAGE_SIZEAli Mohammad Pur
2022-12-12AK: Change quicksort comments to standard // stylekleines Filmröllchen
2022-12-12AK: Introduce cutoff to insertion sort for QuicksortMarc Luqué
Implement insertion sort in AK. The cutoff value 7 is a magic number here, values [5, 15] should work well. Main idea of the cutoff is to reduce recursion performed by quicksort to speed up sorting of small partitions.
2022-12-12AK: Introduce Indexable conceptkleines Filmröllchen
This was dearly missing and can be used in many existing templates.
2022-12-11AK: Specialise AK::is() for NNRP<T>Ali Mohammad Pur
This is used by the Jakt runtime.
2022-12-11AK: Add an identity implementation of StringView::from_string_literal()Ali Mohammad Pur
This is required for the Jakt runtime.